本文整理汇总了Java中org.onosproject.vtnrsc.SubnetId类的典型用法代码示例。如果您正苦于以下问题:Java SubnetId类的具体用法?Java SubnetId怎么用?Java SubnetId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SubnetId类属于org.onosproject.vtnrsc包,在下文中一共展示了SubnetId类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getGwIpAndMac
import org.onosproject.vtnrsc.SubnetId; //导入依赖的package包/类
private List getGwIpAndMac(VirtualPort port) {
List list = new ArrayList();
MacAddress gwMac = null;
SubnetId subnetId = null;
IpAddress gwIp = null;
Iterator<FixedIp> fixips = port.fixedIps().iterator();
if (fixips.hasNext()) {
FixedIp fixip = fixips.next();
subnetId = fixip.subnetId();
gwIp = subnetService.getSubnet(subnetId).gatewayIp();
FixedIp fixedGwIp = FixedIp.fixedIp(fixip.subnetId(), gwIp);
VirtualPort gwPort = virtualPortService.getPort(fixedGwIp);
if (gwPort == null) {
gwPort = VtnData.getPort(vPortStore, fixedGwIp);
}
gwMac = gwPort.macAddress();
}
list.add(gwIp);
list.add(gwMac);
return list;
}
示例2: activate
import org.onosproject.vtnrsc.SubnetId; //导入依赖的package包/类
@Activate
public void activate() {
appId = coreService.registerApplication(VTNRSC_APP);
KryoNamespace.Builder serializer = KryoNamespace
.newBuilder()
.register(KryoNamespaces.API)
.register(RouterId.class, TenantId.class, VirtualPortId.class,
RouterInterface.class, SubnetId.class);
routerInterfaceStore = storageService
.<SubnetId, RouterInterface>eventuallyConsistentMapBuilder()
.withName(ROUTER_INTERFACE).withSerializer(serializer)
.withTimestampProvider((k, v) -> new WallClockTimestamp())
.build();
routerInterfaceStore.addListener(routerInterfaceListener);
log.info("Started");
}
示例3: activate
import org.onosproject.vtnrsc.SubnetId; //导入依赖的package包/类
@Activate
public void activate() {
appId = coreService.registerApplication(VTNRSC_APP);
subnetStore = storageService.<SubnetId, Subnet>consistentMapBuilder()
.withName(SUBNET)
.withApplicationId(appId)
.withPurgeOnUninstall()
.withSerializer(Serializer.using(Arrays.asList(KryoNamespaces.API),
Subnet.class,
SubnetId.class,
TenantNetworkId.class,
TenantId.class,
HostRoute.class,
DefaultHostRoute.class,
Subnet.Mode.class,
AllocationPool.class,
DefaultAllocationPool.class,
DefaultSubnet.class,
IpAddress.Version.class))
.build().asJavaMap();
log.info("Started");
}
示例4: getGatewayMac
import org.onosproject.vtnrsc.SubnetId; //导入依赖的package包/类
@Override
public MacAddress getGatewayMac(HostId hostId) {
checkNotNull(hostId, "hostId cannot be null");
Host host = hostService.getHost(hostId);
String ifaceId = host.annotations().value(IFACEID);
VirtualPortId hPortId = VirtualPortId.portId(ifaceId);
VirtualPort hPort = virtualPortService.getPort(hPortId);
SubnetId subnetId = hPort.fixedIps().iterator().next().subnetId();
Subnet subnet = subnetService.getSubnet(subnetId);
IpAddress gatewayIp = subnet.gatewayIp();
Iterable<VirtualPort> virtualPorts = virtualPortService.getPorts();
MacAddress macAddress = null;
for (VirtualPort port : virtualPorts) {
Set<FixedIp> fixedIpSet = port.fixedIps();
for (FixedIp fixedIp : fixedIpSet) {
if (fixedIp.ip().equals(gatewayIp)) {
macAddress = port.macAddress();
}
}
}
return macAddress;
}
示例5: execute
import org.onosproject.vtnrsc.SubnetId; //导入依赖的package包/类
@Override
protected void execute() {
RouterInterfaceService service = get(RouterInterfaceService.class);
try {
RouterInterface routerInterface = service
.getRouterInterface(SubnetId.subnetId(subnetId));
if (routerInterface == null) {
print(null, "subnet ID of interface doesn't exist");
return;
}
service.removeRouterInterface(routerInterface);
} catch (Exception e) {
print(null, e.getMessage());
}
}
示例6: execute
import org.onosproject.vtnrsc.SubnetId; //导入依赖的package包/类
@Override
protected void execute() {
SubnetService service = get(SubnetService.class);
if (id == null || networkId == null || tenantId == null) {
print("id,networkId,tenantId can not be null");
return;
}
Subnet subnet = new DefaultSubnet(SubnetId.subnetId(id), subnetName,
TenantNetworkId.networkId(networkId),
TenantId.tenantId(tenantId), ipVersion,
cidr == null ? null : IpPrefix.valueOf(cidr),
gatewayIp == null ? null : IpAddress.valueOf(gatewayIp),
dhcpEnabled, shared, hostRoutes,
ipV6AddressMode == null ? null : Mode.valueOf(ipV6AddressMode),
ipV6RaMode == null ? null : Mode.valueOf(ipV6RaMode),
allocationPools);
Set<Subnet> subnetsSet = Sets.newHashSet(subnet);
service.createSubnets(subnetsSet);
}
示例7: execute
import org.onosproject.vtnrsc.SubnetId; //导入依赖的package包/类
@Override
protected void execute() {
SubnetService service = get(SubnetService.class);
if (id == null || networkId == null || tenantId == null) {
print("id,networkId,tenantId can not be null");
return;
}
Subnet subnet = new DefaultSubnet(SubnetId.subnetId(id), subnetName,
TenantNetworkId.networkId(networkId),
TenantId.tenantId(tenantId), ipVersion,
cidr == null ? null : IpPrefix.valueOf(cidr),
gatewayIp == null ? null : IpAddress.valueOf(gatewayIp),
dhcpEnabled, shared, hostRoutes,
ipV6AddressMode == null ? null : Mode.valueOf(ipV6AddressMode),
ipV6RaMode == null ? null : Mode.valueOf(ipV6RaMode),
allocationPools);
Set<Subnet> subnetsSet = Sets.newHashSet();
subnetsSet.add(subnet);
service.updateSubnets(subnetsSet);
}
示例8: activate
import org.onosproject.vtnrsc.SubnetId; //导入依赖的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");
}
示例9: testEquals
import org.onosproject.vtnrsc.SubnetId; //导入依赖的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 SubnetId subnet = SubnetId.subnetId(subnetIdStr);
RouterInterface ri1 = RouterInterface.routerInterface(subnet, portId,
routerId1,
tenantId);
RouterInterface ri2 = RouterInterface.routerInterface(subnet, portId,
routerId1,
tenantId);
RouterInterface ri3 = RouterInterface.routerInterface(subnet, portId,
routerId2,
tenantId);
new EqualsTester().addEqualityGroup(ri1, ri2).addEqualityGroup(ri3)
.testEquals();
}
示例10: testConstruction
import org.onosproject.vtnrsc.SubnetId; //导入依赖的package包/类
/**
* Checks the construction of a RouterInterface object.
*/
@Test
public void testConstruction() {
final TenantId tenantId = TenantId.tenantId(tenantIdStr);
final VirtualPortId portId = VirtualPortId.portId(virtualPortId);
final RouterId routerId1 = RouterId.valueOf(routeIdStr1);
final SubnetId subnet = SubnetId.subnetId(subnetIdStr);
RouterInterface ri1 = RouterInterface.routerInterface(subnet, portId,
routerId1,
tenantId);
assertThat(portId, is(notNullValue()));
assertThat(portId, is(ri1.portId()));
assertThat(tenantId, is(notNullValue()));
assertThat(tenantId, is(ri1.tenantId()));
assertThat(routerId1, is(notNullValue()));
assertThat(routerId1, is(ri1.routerId()));
assertThat(subnet, is(notNullValue()));
assertThat(subnet, is(ri1.subnetId()));
}
示例11: getSubnet
import org.onosproject.vtnrsc.SubnetId; //导入依赖的package包/类
@GET
@Path("{subnetUUID}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response getSubnet(@PathParam("subnetUUID") String id) {
if (!get(SubnetService.class).exists(SubnetId.subnetId(id))) {
return Response.status(NOT_FOUND)
.entity(SUBNET_NOT_FOUND).build();
}
Subnet sub = nullIsNotFound(get(SubnetService.class)
.getSubnet(SubnetId.subnetId(id)),
SUBNET_NOT_FOUND);
ObjectNode result = new ObjectMapper().createObjectNode();
result.set("subnet", new SubnetCodec().encode(sub, this));
return ok(result.toString()).build();
}
示例12: deleteSingleSubnet
import org.onosproject.vtnrsc.SubnetId; //导入依赖的package包/类
@DELETE
@Path("{subnetUUID}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response deleteSingleSubnet(@PathParam("subnetUUID") String id)
throws IOException {
try {
SubnetId subId = SubnetId.subnetId(id);
Set<SubnetId> subIds = new HashSet<>();
subIds.add(subId);
get(SubnetService.class).removeSubnets(subIds);
return Response.noContent().entity("SUCCESS").build();
} catch (Exception e) {
return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
.build();
}
}
示例13: getSubnetOfFloatingIP
import org.onosproject.vtnrsc.SubnetId; //导入依赖的package包/类
private Subnet getSubnetOfFloatingIP(FloatingIp floatingIp) {
DeviceId exVmPortId = DeviceId
.deviceId(floatingIp.id().floatingIpId().toString());
Collection<VirtualPort> exVmPortList = virtualPortService
.getPorts(exVmPortId);
VirtualPort exVmPort = null;
if (exVmPortList != null) {
exVmPort = exVmPortList.iterator().next();
}
if (exVmPort == null) {
return null;
}
Set<FixedIp> fixedIps = exVmPort.fixedIps();
SubnetId subnetId = null;
for (FixedIp f : fixedIps) {
IpAddress fp = f.ip();
if (fp.equals(floatingIp.floatingIp())) {
subnetId = f.subnetId();
break;
}
}
if (subnetId == null) {
return null;
}
Subnet subnet = subnetService.getSubnet(subnetId);
return subnet;
}
示例14: removeSubnets
import org.onosproject.vtnrsc.SubnetId; //导入依赖的package包/类
@Override
public boolean removeSubnets(Iterable<SubnetId> subnetIds) {
checkNotNull(subnetIds, SUBNET_ID_NULL);
for (SubnetId subnetId : subnetIds) {
subnetStore.remove(subnetId);
if (subnetStore.containsKey(subnetId)) {
log.debug("The subnet created is failed whose identifier is {}",
subnetId.toString());
return false;
}
}
return true;
}
示例15: activate
import org.onosproject.vtnrsc.SubnetId; //导入依赖的package包/类
@Activate
public void activate() {
appId = coreService.registerApplication(VTNRSC_APP);
eventDispatcher.addSink(VirtualPortEvent.class, listenerRegistry);
vPortStore = storageService.<VirtualPortId, VirtualPort>eventuallyConsistentMapBuilder()
.withName(VIRTUALPORT)
.withSerializer(KryoNamespace.newBuilder().register(KryoNamespaces.API)
.register(MultiValuedTimestamp.class)
.register(VirtualPortId.class,
TenantNetworkId.class,
VirtualPort.State.class,
TenantId.class,
AllowedAddressPair.class,
FixedIp.class,
BindingHostId.class,
SecurityGroup.class,
SubnetId.class,
IpAddress.class,
DefaultVirtualPort.class))
.withTimestampProvider((k, v) ->new WallClockTimestamp())
.build();
vPortStore.addListener(virtualPortListener);
log.info("Started");
}