当前位置: 首页>>代码示例>>Java>>正文


Java TenantId类代码示例

本文整理汇总了Java中org.onosproject.incubator.net.virtual.TenantId的典型用法代码示例。如果您正苦于以下问题:Java TenantId类的具体用法?Java TenantId怎么用?Java TenantId使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TenantId类属于org.onosproject.incubator.net.virtual包,在下文中一共展示了TenantId类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createVirtualNetwork

import org.onosproject.incubator.net.virtual.TenantId; //导入依赖的package包/类
/**
 * Creates a virtual network from the JSON input stream.
 *
 * @param stream tenant identifier JSON stream
 * @return status of the request - CREATED if the JSON is correct,
 * BAD_REQUEST if the JSON is invalid
 * @onos.rsModel TenantId
 */
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createVirtualNetwork(InputStream stream) {
    try {
        final TenantId tid = TenantId.tenantId(getFromJsonStream(stream, "id").asText());
        VirtualNetwork newVnet = vnetAdminService.createVirtualNetwork(tid);
        UriBuilder locationBuilder = uriInfo.getBaseUriBuilder()
                .path("vnets")
                .path(newVnet.id().toString());
        return Response
                .created(locationBuilder.build())
                .build();
    } catch (IOException e) {
        throw new IllegalArgumentException(e);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:VirtualNetworkWebResource.java

示例2: addTenantId

import org.onosproject.incubator.net.virtual.TenantId; //导入依赖的package包/类
/**
 * Creates a tenant with the given tenant identifier.
 *
 * @param stream TenantId JSON stream
 * @return status of the request - CREATED if the JSON is correct,
 * BAD_REQUEST if the JSON is invalid
 * @onos.rsModel TenantId
 */
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response addTenantId(InputStream stream) {
    try {
        final TenantId tid = getTenantIdFromJsonStream(stream);
        vnetAdminService.registerTenantId(tid);
        final TenantId resultTid = getExistingTenantId(vnetAdminService, tid);
        UriBuilder locationBuilder = uriInfo.getBaseUriBuilder()
                .path("tenants")
                .path(resultTid.id());
        return Response
                .created(locationBuilder.build())
                .build();
    } catch (IOException e) {
        throw new IllegalArgumentException(e);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:TenantWebResource.java

示例3: testRegisterUnregisterTenantId

import org.onosproject.incubator.net.virtual.TenantId; //导入依赖的package包/类
/**
 * Tests registering/unregistering a tenant id.
 */
@Test
public void testRegisterUnregisterTenantId() {
    manager.unregisterTenantId(TenantId.tenantId(tenantIdValue1));
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    manager.registerTenantId(TenantId.tenantId(tenantIdValue2));
    Collection<TenantId> tenantIdCollection = manager.getTenantIds();
    assertEquals("The tenantId set size did not match.", 2, tenantIdCollection.size());

    manager.unregisterTenantId(TenantId.tenantId(tenantIdValue1));
    manager.unregisterTenantId(TenantId.tenantId(tenantIdValue2));
    tenantIdCollection = manager.getTenantIds();
    assertTrue("The tenantId set should be empty.", tenantIdCollection.isEmpty());

    // Validate that the events were all received in the correct order.
    validateEvents(VirtualNetworkEvent.Type.TENANT_UNREGISTERED, VirtualNetworkEvent.Type.TENANT_REGISTERED,
                   VirtualNetworkEvent.Type.TENANT_REGISTERED, VirtualNetworkEvent.Type.TENANT_UNREGISTERED,
                   VirtualNetworkEvent.Type.TENANT_UNREGISTERED);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:22,代码来源:VirtualNetworkManagerTest.java

示例4: addNetwork

import org.onosproject.incubator.net.virtual.TenantId; //导入依赖的package包/类
@Override
public VirtualNetwork addNetwork(TenantId tenantId) {

    checkState(tenantIdSet.contains(tenantId), "The tenant has not been registered. " + tenantId.id());
    VirtualNetwork virtualNetwork = new DefaultVirtualNetwork(genNetworkId(), tenantId);
    //TODO update both maps in one transaction.
    networkIdVirtualNetworkMap.put(virtualNetwork.id(), virtualNetwork);

    Set<NetworkId> networkIdSet = tenantIdNetworkIdSetMap.get(tenantId);
    if (networkIdSet == null) {
        networkIdSet = new HashSet<>();
    }
    networkIdSet.add(virtualNetwork.id());
    tenantIdNetworkIdSetMap.put(tenantId, networkIdSet);

    return virtualNetwork;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:DistributedVirtualNetworkStore.java

示例5: getMappedVirtualPort

import org.onosproject.incubator.net.virtual.TenantId; //导入依赖的package包/类
/**
 * Find the corresponding virtual port with the physical port.
 *
 * @param cp the connect point for the physical network
 * @return a virtual port
 */
private VirtualPort getMappedVirtualPort(ConnectPoint cp) {
    Set<TenantId> tIds = vnaService.getTenantIds();

    Set<VirtualNetwork> vNetworks = new HashSet<>();
    tIds.forEach(tid -> vNetworks.addAll(vnaService.getVirtualNetworks(tid)));

    for (VirtualNetwork vNet : vNetworks) {
        Set<VirtualDevice> vDevices = vnaService.getVirtualDevices(vNet.id());

        Set<VirtualPort> vPorts = new HashSet<>();
        vDevices.forEach(dev -> vPorts
                .addAll(vnaService.getVirtualPorts(dev.networkId(), dev.id())));

        VirtualPort vPort = vPorts.stream()
                .filter(vp -> vp.realizedBy().equals(cp))
                .findFirst().orElse(null);

        if (vPort != null) {
            return vPort;
        }
    }

    return null;
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:31,代码来源:DefaultVirtualPacketProvider.java

示例6: topologyChanged

import org.onosproject.incubator.net.virtual.TenantId; //导入依赖的package包/类
@Override
public void topologyChanged(Set<Set<ConnectPoint>> clusters) {
    Set<TenantId> tenantIds = getTenantIds();
    tenantIds.forEach(tenantId -> {
        Set<VirtualNetwork> virtualNetworks = getVirtualNetworks(tenantId);

        virtualNetworks.forEach(virtualNetwork -> {
            Set<VirtualLink> virtualLinks = getVirtualLinks(virtualNetwork.id());

            virtualLinks.forEach(virtualLink -> {
                if (isVirtualLinkInCluster(virtualNetwork.id(),
                                           virtualLink, clusters)) {
                    store.updateLink(virtualLink, virtualLink.tunnelId(),
                                     Link.State.ACTIVE);
                } else {
                    store.updateLink(virtualLink, virtualLink.tunnelId(),
                                     Link.State.INACTIVE);
                }
            });
        });
    });
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:23,代码来源:VirtualNetworkManager.java

示例7: testGetLinkByNullSrc

import org.onosproject.incubator.net.virtual.TenantId; //导入依赖的package包/类
/**
 * Tests the getLink() method using a null src connect point.
 */
@Test(expected = NullPointerException.class)
public void testGetLinkByNullSrc() {

    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
    VirtualDevice srcVirtualDevice =
            manager.createVirtualDevice(virtualNetwork.id(), DID1);
    VirtualDevice dstVirtualDevice =
            manager.createVirtualDevice(virtualNetwork.id(), DID2);
    ConnectPoint src = new ConnectPoint(srcVirtualDevice.id(), PortNumber.portNumber(1));
    ConnectPoint dst = new ConnectPoint(dstVirtualDevice.id(), PortNumber.portNumber(2));
    manager.createVirtualLink(virtualNetwork.id(), src, dst);
    manager.createVirtualLink(virtualNetwork.id(), dst, src);

    LinkService linkService = manager.get(virtualNetwork.id(), LinkService.class);

    // test the getLink() method with a null src connect point.
    linkService.getLink(null, dst);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:23,代码来源:VirtualNetworkLinkManagerTest.java

示例8: testGetLinkByNullDst

import org.onosproject.incubator.net.virtual.TenantId; //导入依赖的package包/类
/**
 * Tests the getLink() method using a null dst connect point.
 */
@Test(expected = NullPointerException.class)
public void testGetLinkByNullDst() {

    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
    VirtualDevice srcVirtualDevice =
            manager.createVirtualDevice(virtualNetwork.id(), DID1);
    VirtualDevice dstVirtualDevice =
            manager.createVirtualDevice(virtualNetwork.id(), DID2);
    ConnectPoint src = new ConnectPoint(srcVirtualDevice.id(), PortNumber.portNumber(1));
    ConnectPoint dst = new ConnectPoint(dstVirtualDevice.id(), PortNumber.portNumber(2));
    manager.createVirtualLink(virtualNetwork.id(), src, dst);
    manager.createVirtualLink(virtualNetwork.id(), dst, src);

    LinkService linkService = manager.get(virtualNetwork.id(), LinkService.class);

    // test the getLink() method with a null dst connect point.
    linkService.getLink(src, null);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:23,代码来源:VirtualNetworkLinkManagerTest.java

示例9: testRegisterUnregisterTenantId

import org.onosproject.incubator.net.virtual.TenantId; //导入依赖的package包/类
/**
 * Tests registering/unregistering a tenant id.
 */
@Test
public void testRegisterUnregisterTenantId() {
    manager.unregisterTenantId(TenantId.tenantId(tenantIdValue1));
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    manager.registerTenantId(TenantId.tenantId(tenantIdValue2));
    Collection<TenantId> tenantIdCollection = manager.getTenantIds();
    assertEquals("The tenantId set size did not match.", 2, tenantIdCollection.size());

    manager.unregisterTenantId(TenantId.tenantId(tenantIdValue1));
    manager.unregisterTenantId(TenantId.tenantId(tenantIdValue2));
    tenantIdCollection = manager.getTenantIds();
    assertTrue("The tenantId set should be empty.", tenantIdCollection.isEmpty());

    // Validate that the events were all received in the correct order.
    validateEvents(VirtualNetworkEvent.Type.TENANT_REGISTERED,
                   VirtualNetworkEvent.Type.TENANT_REGISTERED,
                   VirtualNetworkEvent.Type.TENANT_UNREGISTERED,
                   VirtualNetworkEvent.Type.TENANT_UNREGISTERED);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:23,代码来源:VirtualNetworkManagerTest.java

示例10: testAddSameVirtualLink

import org.onosproject.incubator.net.virtual.TenantId; //导入依赖的package包/类
/**
 * Tests adding the same virtual link twice.
 */
@Test(expected = IllegalStateException.class)
public void testAddSameVirtualLink() {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork1 =
            manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
    VirtualDevice srcVirtualDevice =
            manager.createVirtualDevice(virtualNetwork1.id(), DID1);
    VirtualDevice dstVirtualDevice =
            manager.createVirtualDevice(virtualNetwork1.id(), DID2);
    ConnectPoint src = new ConnectPoint(srcVirtualDevice.id(), PortNumber.portNumber(1));
    manager.createVirtualPort(virtualNetwork1.id(), src.deviceId(), src.port(),
                              new ConnectPoint(srcVirtualDevice.id(), src.port()));

    ConnectPoint dst = new ConnectPoint(dstVirtualDevice.id(), PortNumber.portNumber(2));
    manager.createVirtualPort(virtualNetwork1.id(), dst.deviceId(), dst.port(),
                              new ConnectPoint(dstVirtualDevice.id(), dst.port()));

    manager.createVirtualLink(virtualNetwork1.id(), src, dst);
    manager.createVirtualLink(virtualNetwork1.id(), src, dst);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:24,代码来源:VirtualNetworkManagerTest.java

示例11: setupVnet

import org.onosproject.incubator.net.virtual.TenantId; //导入依赖的package包/类
/**
 * Sets up a virtual network with hosts.
 *
 * @return virtual network
 */
private VirtualNetwork setupVnet() {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));

    VirtualDevice virtualDevice1 =
            manager.createVirtualDevice(virtualNetwork.id(), DID1);
    VirtualDevice virtualDevice2 =
            manager.createVirtualDevice(virtualNetwork.id(), DID2);

    ConnectPoint hostCp1 = new ConnectPoint(DID1, P1);
    ConnectPoint hostCp2 = new ConnectPoint(DID2, P2);
    manager.createVirtualPort(virtualNetwork.id(), hostCp1.deviceId(), hostCp1.port(),
            new ConnectPoint(virtualDevice1.id(), hostCp1.port()));
    manager.createVirtualPort(virtualNetwork.id(), hostCp2.deviceId(), hostCp2.port(),
            new ConnectPoint(virtualDevice2.id(), hostCp2.port()));

    manager.createVirtualHost(virtualNetwork.id(), HID1, MAC1, VLAN1, LOC1, IPSET1);
    manager.createVirtualHost(virtualNetwork.id(), HID2, MAC2, VLAN2, LOC2, IPSET2);
    return virtualNetwork;
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:26,代码来源:VirtualNetworkHostManagerTest.java

示例12: setupEmptyVnet

import org.onosproject.incubator.net.virtual.TenantId; //导入依赖的package包/类
/**
 * Sets up a virtual network with no hosts.
 *
 * @return virtual network
 */
private VirtualNetwork setupEmptyVnet() {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));

    VirtualDevice virtualDevice1 =
            manager.createVirtualDevice(virtualNetwork.id(), DID1);
    VirtualDevice virtualDevice2 =
            manager.createVirtualDevice(virtualNetwork.id(), DID2);

    ConnectPoint hostCp1 = new ConnectPoint(DID1, P1);
    ConnectPoint hostCp2 = new ConnectPoint(DID2, P2);
    manager.createVirtualPort(virtualNetwork.id(), hostCp1.deviceId(), hostCp1.port(),
            new ConnectPoint(virtualDevice1.id(), hostCp1.port()));
    manager.createVirtualPort(virtualNetwork.id(), hostCp2.deviceId(), hostCp2.port(),
            new ConnectPoint(virtualDevice2.id(), hostCp2.port()));

    return virtualNetwork;
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:24,代码来源:VirtualNetworkHostManagerTest.java

示例13: testGetDeviceType

import org.onosproject.incubator.net.virtual.TenantId; //导入依赖的package包/类
/**
 * Tests querying for a device and available devices by device type.
 */
@Test
public void testGetDeviceType() {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
    manager.createVirtualDevice(virtualNetwork.id(), DID1);
    manager.createVirtualDevice(virtualNetwork.id(), DID2);

    DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class);

    // test the getDevices(Type) method.
    Iterator<Device> it = deviceService.getDevices(Device.Type.VIRTUAL).iterator();
    assertEquals("The device set size did not match.", 2, Iterators.size(it));
    Iterator<Device> it2 = deviceService.getDevices(Device.Type.SWITCH).iterator();
    assertEquals("The device set size did not match.", 0, Iterators.size(it2));

    // test the getAvailableDevices(Type) method.
    Iterator<Device> it3 = deviceService.getAvailableDevices(Device.Type.VIRTUAL).iterator();
    assertEquals("The device set size did not match.", 2, Iterators.size(it3));
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:23,代码来源:VirtualNetworkDeviceManagerTest.java

示例14: testGetPorts

import org.onosproject.incubator.net.virtual.TenantId; //导入依赖的package包/类
/**
 * Tests querying the ports of a device by device identifier.
 */
@Test
public void testGetPorts() {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
    VirtualDevice virtualDevice = manager.createVirtualDevice(virtualNetwork.id(), DID1);
    manager.createVirtualDevice(virtualNetwork.id(), DID2);

    DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class);

    ConnectPoint cp = new ConnectPoint(virtualDevice.id(), PortNumber.portNumber(1));

    manager.createVirtualPort(virtualNetwork.id(), virtualDevice.id(), PortNumber.portNumber(1), cp);
    manager.createVirtualPort(virtualNetwork.id(), virtualDevice.id(), PortNumber.portNumber(2), cp);

    // test the getPorts() method
    assertEquals("The port set size did not match.", 2,
                 deviceService.getPorts(DID1).size());
    assertEquals("The port set size did not match.", 0,
                 deviceService.getPorts(DID2).size());
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:24,代码来源:VirtualNetworkDeviceManagerTest.java

示例15: testGetPort

import org.onosproject.incubator.net.virtual.TenantId; //导入依赖的package包/类
/**
 * Tests querying the port of a device by device identifier and port number.
 */
@Test
public void testGetPort() {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
    VirtualDevice virtualDevice = manager.createVirtualDevice(virtualNetwork.id(), DID1);
    manager.createVirtualDevice(virtualNetwork.id(), DID2);

    DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class);

    ConnectPoint cp = new ConnectPoint(virtualDevice.id(), PortNumber.portNumber(1));

    VirtualPort virtualPort1 = manager.createVirtualPort(virtualNetwork.id(), virtualDevice.id(),
                                                         PortNumber.portNumber(1), cp);
    manager.createVirtualPort(virtualNetwork.id(), virtualDevice.id(), PortNumber.portNumber(2), cp);

    // test the getPort() method
    assertEquals("The port did not match as expected.", virtualPort1,
                 deviceService.getPort(DID1, PortNumber.portNumber(1)));
    assertNotEquals("The port did not match as expected.", virtualPort1,
                    deviceService.getPort(DID1, PortNumber.portNumber(3)));
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:25,代码来源:VirtualNetworkDeviceManagerTest.java


注:本文中的org.onosproject.incubator.net.virtual.TenantId类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。