本文整理汇总了Java中org.onosproject.vtnrsc.RouterGateway类的典型用法代码示例。如果您正苦于以下问题:Java RouterGateway类的具体用法?Java RouterGateway怎么用?Java RouterGateway使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RouterGateway类属于org.onosproject.vtnrsc包,在下文中一共展示了RouterGateway类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: activate
import org.onosproject.vtnrsc.RouterGateway; //导入依赖的package包/类
@Activate
public void activate() {
appId = coreService.registerApplication(VTNRSC_APP);
KryoNamespace.Builder serializer = KryoNamespace
.newBuilder()
.register(KryoNamespaces.API)
.register(Router.class, RouterId.class, DefaultRouter.class,
TenantNetworkId.class, TenantId.class,
VirtualPortId.class, DefaultRouter.class,
RouterGateway.class, Router.Status.class,
SubnetId.class, FixedIp.class);
routerStore = storageService
.<RouterId, Router>eventuallyConsistentMapBuilder()
.withName(ROUTER).withSerializer(serializer)
.withTimestampProvider((k, v) -> new WallClockTimestamp())
.build();
routerStore.addListener(routerListener);
log.info("Started");
}
示例2: testConstruction
import org.onosproject.vtnrsc.RouterGateway; //导入依赖的package包/类
/**
* Checks the construction of a DefaultRouter object.
*/
@Test
public void testConstruction() {
final TenantId tenantId = TenantId.tenantId(tenantIdStr);
final VirtualPortId portId = VirtualPortId.portId(virtualPortId);
final RouterId routerId = RouterId.valueOf(routeIdStr1);
final TenantNetworkId networkId = TenantNetworkId
.networkId(tenantNetworkId);
final RouterGateway routerGateway = RouterGateway.routerGateway(
networkId,
true,
Collections
.emptySet());
Router r1 = new DefaultRouter(routerId, routerName, false,
Router.Status.ACTIVE, false,
routerGateway, portId, tenantId, null);
assertThat(routerId, is(notNullValue()));
assertThat(routerId, is(r1.id()));
assertThat(tenantId, is(notNullValue()));
assertThat(tenantId, is(r1.tenantId()));
assertThat(routerGateway, is(notNullValue()));
assertThat(routerGateway, is(r1.externalGatewayInfo()));
}
示例3: verifyRouterData
import org.onosproject.vtnrsc.RouterGateway; //导入依赖的package包/类
/**
* Verifies validity of Router data.
*
* @param routers router instance
*/
private void verifyRouterData(Router routers) {
checkNotNull(routers, ROUTER_NOT_NULL);
if (routers.gatewayPortid() != null
&& !virtualPortService.exists(routers.gatewayPortid())) {
log.debug("The gateway port ID is not exist whose identifier is {}",
routers.gatewayPortid().toString());
throw new IllegalArgumentException("gateway port ID doesn't exist");
}
if (routers.externalGatewayInfo() != null) {
RouterGateway routerGateway = routers.externalGatewayInfo();
if (!tenantNetworkService.exists(routerGateway.networkId())) {
log.debug("The network ID of gateway info is not exist whose identifier is {}",
routers.id().toString());
throw new IllegalArgumentException(
"network ID of gateway info doesn't exist");
}
Iterable<FixedIp> fixedIps = routerGateway.externalFixedIps();
for (FixedIp fixedIp : fixedIps) {
if (!subnetService.exists(fixedIp.subnetId())) {
log.debug("The subnet ID of gateway info is not exist whose identifier is {}",
routers.id().toString());
throw new IllegalArgumentException(
"subnet ID of gateway info doesn't exist");
}
}
}
}
示例4: testEquals
import org.onosproject.vtnrsc.RouterGateway; //导入依赖的package包/类
/**
* Checks the operation of equals().
*/
@Test
public void testEquals() {
final TenantId tenantId = TenantId.tenantId(tenantIdStr);
final VirtualPortId portId = VirtualPortId.portId(virtualPortId);
final RouterId routerId1 = RouterId.valueOf(routeIdStr1);
final RouterId routerId2 = RouterId.valueOf(routeIdStr2);
final TenantNetworkId networkId = TenantNetworkId
.networkId(tenantNetworkId);
final RouterGateway routerGateway = RouterGateway.routerGateway(
networkId,
true,
Collections
.emptySet());
Router r1 = new DefaultRouter(routerId1, routerName, false,
Router.Status.ACTIVE, false,
routerGateway, portId, tenantId, null);
Router r2 = new DefaultRouter(routerId1, routerName, false,
Router.Status.ACTIVE, false,
routerGateway, portId, tenantId, null);
Router r3 = new DefaultRouter(routerId2, routerName, false,
Router.Status.ACTIVE, false,
routerGateway, portId, tenantId, null);
new EqualsTester().addEqualityGroup(r1, r2).addEqualityGroup(r3)
.testEquals();
}
示例5: encode
import org.onosproject.vtnrsc.RouterGateway; //导入依赖的package包/类
@Override
public ObjectNode encode(RouterGateway routerGateway, CodecContext context) {
checkNotNull(routerGateway, "routerGateway cannot be null");
ObjectNode result = context.mapper().createObjectNode()
.put("network_id", routerGateway.networkId().toString());
result.set("external_fixed_ips", new FixedIpCodec()
.encode(routerGateway.externalFixedIps(), context));
return result;
}
示例6: jsonNodeToGateway
import org.onosproject.vtnrsc.RouterGateway; //导入依赖的package包/类
/**
* Changes JsonNode Gateway to the Gateway.
*
* @param gateway the gateway JsonNode
* @return gateway
*/
private RouterGateway jsonNodeToGateway(JsonNode gateway) {
checkNotNull(gateway, JSON_NOT_NULL);
if (!gateway.hasNonNull("network_id")) {
throw new IllegalArgumentException("network_id should not be null");
} else if (gateway.get("network_id").asText().isEmpty()) {
throw new IllegalArgumentException("network_id should not be empty");
}
TenantNetworkId networkId = TenantNetworkId
.networkId(gateway.get("network_id").asText());
if (!gateway.hasNonNull("enable_snat")) {
throw new IllegalArgumentException("enable_snat should not be null");
} else if (gateway.get("enable_snat").asText().isEmpty()) {
throw new IllegalArgumentException("enable_snat should not be empty");
}
checkArgument(gateway.get("enable_snat").isBoolean(),
"enable_snat should be boolean");
boolean enableSnat = gateway.get("enable_snat").asBoolean();
if (!gateway.hasNonNull("external_fixed_ips")) {
throw new IllegalArgumentException("external_fixed_ips should not be null");
} else if (gateway.get("external_fixed_ips").isNull()) {
throw new IllegalArgumentException("external_fixed_ips should not be empty");
}
Iterable<FixedIp> fixedIpList = jsonNodeToFixedIp(gateway
.get("external_fixed_ips"));
RouterGateway gatewayObj = RouterGateway
.routerGateway(networkId, enableSnat, Sets.newHashSet(fixedIpList));
return gatewayObj;
}
示例7: changeJsonToSub
import org.onosproject.vtnrsc.RouterGateway; //导入依赖的package包/类
/**
* Returns a collection of floatingIps from floatingIpNodes.
*
* @param routerNode the router json node
* @return routers a collection of router
* @throws Exception when any argument is illegal
*/
public Collection<Router> changeJsonToSub(JsonNode routerNode)
throws Exception {
checkNotNull(routerNode, JSON_NOT_NULL);
Map<RouterId, Router> subMap = new HashMap<RouterId, Router>();
if (!routerNode.hasNonNull("id")) {
new IllegalArgumentException("id should not be null");
} else if (routerNode.get("id").asText().isEmpty()) {
throw new IllegalArgumentException("id should not be empty");
}
RouterId id = RouterId.valueOf(routerNode.get("id").asText());
if (!routerNode.hasNonNull("tenant_id")) {
throw new IllegalArgumentException("tenant_id should not be null");
} else if (routerNode.get("tenant_id").asText().isEmpty()) {
throw new IllegalArgumentException("tenant_id should not be empty");
}
TenantId tenantId = TenantId
.tenantId(routerNode.get("tenant_id").asText());
VirtualPortId gwPortId = null;
if (routerNode.hasNonNull("gw_port_id")) {
gwPortId = VirtualPortId
.portId(routerNode.get("gw_port_id").asText());
}
if (!routerNode.hasNonNull("status")) {
throw new IllegalArgumentException("status should not be null");
} else if (routerNode.get("status").asText().isEmpty()) {
throw new IllegalArgumentException("status should not be empty");
}
Status status = Status.valueOf(routerNode.get("status").asText());
String routerName = null;
if (routerNode.hasNonNull("name")) {
routerName = routerNode.get("name").asText();
}
boolean adminStateUp = true;
checkArgument(routerNode.get("admin_state_up").isBoolean(),
"admin_state_up should be boolean");
if (routerNode.hasNonNull("admin_state_up")) {
adminStateUp = routerNode.get("admin_state_up").asBoolean();
}
boolean distributed = false;
if (routerNode.hasNonNull("distributed")) {
distributed = routerNode.get("distributed").asBoolean();
}
RouterGateway gateway = null;
if (routerNode.hasNonNull("external_gateway_info")) {
gateway = jsonNodeToGateway(routerNode
.get("external_gateway_info"));
}
List<String> routes = new ArrayList<String>();
DefaultRouter routerObj = new DefaultRouter(id, routerName,
adminStateUp, status,
distributed, gateway,
gwPortId, tenantId, routes);
subMap.put(id, routerObj);
return Collections.unmodifiableCollection(subMap.values());
}
示例8: changeUpdateJsonToSub
import org.onosproject.vtnrsc.RouterGateway; //导入依赖的package包/类
/**
* Returns a collection of floatingIps from floatingIpNodes.
*
* @param subnode the router json node
* @param routerId the router identify
* @return routers a collection of router
* @throws Exception when any argument is illegal
*/
public Collection<Router> changeUpdateJsonToSub(JsonNode subnode,
String routerId)
throws Exception {
checkNotNull(subnode, JSON_NOT_NULL);
checkNotNull(routerId, "routerId should not be null");
Map<RouterId, Router> subMap = new HashMap<RouterId, Router>();
JsonNode routerNode = subnode.get("router");
RouterId id = RouterId.valueOf(routerId);
Router sub = nullIsNotFound(get(RouterService.class).getRouter(id),
NOT_EXIST);
TenantId tenantId = sub.tenantId();
VirtualPortId gwPortId = null;
if (routerNode.hasNonNull("gw_port_id")) {
gwPortId = VirtualPortId
.portId(routerNode.get("gw_port_id").asText());
}
Status status = sub.status();
String routerName = routerNode.get("name").asText();
checkArgument(routerNode.get("admin_state_up").isBoolean(),
"admin_state_up should be boolean");
boolean adminStateUp = routerNode.get("admin_state_up").asBoolean();
boolean distributed = sub.distributed();
if (routerNode.hasNonNull("distributed")) {
distributed = routerNode.get("distributed").asBoolean();
}
RouterGateway gateway = sub.externalGatewayInfo();
if (routerNode.hasNonNull("external_gateway_info")) {
gateway = jsonNodeToGateway(routerNode
.get("external_gateway_info"));
}
List<String> routes = new ArrayList<String>();
DefaultRouter routerObj = new DefaultRouter(id, routerName,
adminStateUp, status,
distributed, gateway,
gwPortId, tenantId, routes);
subMap.put(id, routerObj);
return Collections.unmodifiableCollection(subMap.values());
}
示例9: changeJsonToSub
import org.onosproject.vtnrsc.RouterGateway; //导入依赖的package包/类
/**
* Returns a collection of floatingIps from floatingIpNodes.
*
* @param routerNode the router json node
* @return routers a collection of router
*/
public Collection<Router> changeJsonToSub(JsonNode routerNode) {
checkNotNull(routerNode, JSON_NOT_NULL);
Map<RouterId, Router> subMap = new HashMap<RouterId, Router>();
if (!routerNode.hasNonNull("id")) {
throw new IllegalArgumentException("id should not be null");
} else if (routerNode.get("id").asText().isEmpty()) {
throw new IllegalArgumentException("id should not be empty");
}
RouterId id = RouterId.valueOf(routerNode.get("id").asText());
if (!routerNode.hasNonNull("tenant_id")) {
throw new IllegalArgumentException("tenant_id should not be null");
} else if (routerNode.get("tenant_id").asText().isEmpty()) {
throw new IllegalArgumentException("tenant_id should not be empty");
}
TenantId tenantId = TenantId
.tenantId(routerNode.get("tenant_id").asText());
VirtualPortId gwPortId = null;
if (routerNode.hasNonNull("gw_port_id")) {
gwPortId = VirtualPortId
.portId(routerNode.get("gw_port_id").asText());
}
if (!routerNode.hasNonNull("status")) {
throw new IllegalArgumentException("status should not be null");
} else if (routerNode.get("status").asText().isEmpty()) {
throw new IllegalArgumentException("status should not be empty");
}
Status status = Status.valueOf(routerNode.get("status").asText());
String routerName = null;
if (routerNode.hasNonNull("name")) {
routerName = routerNode.get("name").asText();
}
boolean adminStateUp = true;
checkArgument(routerNode.get("admin_state_up").isBoolean(),
"admin_state_up should be boolean");
if (routerNode.hasNonNull("admin_state_up")) {
adminStateUp = routerNode.get("admin_state_up").asBoolean();
}
boolean distributed = false;
if (routerNode.hasNonNull("distributed")) {
distributed = routerNode.get("distributed").asBoolean();
}
RouterGateway gateway = null;
if (routerNode.hasNonNull("external_gateway_info")) {
gateway = jsonNodeToGateway(routerNode
.get("external_gateway_info"));
}
List<String> routes = new ArrayList<String>();
DefaultRouter routerObj = new DefaultRouter(id, routerName,
adminStateUp, status,
distributed, gateway,
gwPortId, tenantId, routes);
subMap.put(id, routerObj);
return Collections.unmodifiableCollection(subMap.values());
}
示例10: changeUpdateJsonToSub
import org.onosproject.vtnrsc.RouterGateway; //导入依赖的package包/类
/**
* Returns a collection of floatingIps from floatingIpNodes.
*
* @param subnode the router json node
* @param routerId the router identify
* @return routers a collection of router
*/
public Collection<Router> changeUpdateJsonToSub(JsonNode subnode,
String routerId) {
checkNotNull(subnode, JSON_NOT_NULL);
checkNotNull(routerId, "routerId should not be null");
Map<RouterId, Router> subMap = new HashMap<RouterId, Router>();
JsonNode routerNode = subnode.get("router");
RouterId id = RouterId.valueOf(routerId);
Router sub = nullIsNotFound(get(RouterService.class).getRouter(id),
NOT_EXIST);
TenantId tenantId = sub.tenantId();
VirtualPortId gwPortId = null;
if (routerNode.hasNonNull("gw_port_id")) {
gwPortId = VirtualPortId
.portId(routerNode.get("gw_port_id").asText());
}
Status status = sub.status();
String routerName = routerNode.get("name").asText();
checkArgument(routerNode.get("admin_state_up").isBoolean(),
"admin_state_up should be boolean");
boolean adminStateUp = routerNode.get("admin_state_up").asBoolean();
boolean distributed = sub.distributed();
if (routerNode.hasNonNull("distributed")) {
distributed = routerNode.get("distributed").asBoolean();
}
RouterGateway gateway = sub.externalGatewayInfo();
if (routerNode.hasNonNull("external_gateway_info")) {
gateway = jsonNodeToGateway(routerNode
.get("external_gateway_info"));
}
List<String> routes = new ArrayList<String>();
DefaultRouter routerObj = new DefaultRouter(id, routerName,
adminStateUp, status,
distributed, gateway,
gwPortId, tenantId, routes);
subMap.put(id, routerObj);
return Collections.unmodifiableCollection(subMap.values());
}