Search in sources :

Example 31 with VirtualNetwork

use of org.onosproject.incubator.net.virtual.VirtualNetwork in project onos by opennetworkinglab.

the class DistributedVirtualNetworkStore method addNetwork.

@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;
}
Also used : DefaultVirtualNetwork(org.onosproject.incubator.net.virtual.DefaultVirtualNetwork) VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) DefaultVirtualNetwork(org.onosproject.incubator.net.virtual.DefaultVirtualNetwork) NetworkId(org.onosproject.incubator.net.virtual.NetworkId)

Example 32 with VirtualNetwork

use of org.onosproject.incubator.net.virtual.VirtualNetwork in project onos by opennetworkinglab.

the class DefaultVirtualPacketProvider method getMappedVirtualPort.

/**
 * 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;
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) VirtualPort(org.onosproject.incubator.net.virtual.VirtualPort) TenantId(org.onosproject.net.TenantId) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) HashSet(java.util.HashSet)

Example 33 with VirtualNetwork

use of org.onosproject.incubator.net.virtual.VirtualNetwork in project onos by opennetworkinglab.

the class VirtualNetworkDeviceManagerTest method testIsAvailableByNullId.

/**
 * Tests the isAvailable method using a null device identifier.
 */
@Test(expected = NullPointerException.class)
public void testIsAvailableByNullId() {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
    DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class);
    // test the isAvailable() method with null device id value.
    deviceService.isAvailable(null);
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) DeviceService(org.onosproject.net.device.DeviceService) Test(org.junit.Test)

Example 34 with VirtualNetwork

use of org.onosproject.incubator.net.virtual.VirtualNetwork in project onos by opennetworkinglab.

the class VirtualNetworkDeviceManagerTest method testGetPortStatistics.

/**
 * Tests querying the port statistics of a device by device identifier.
 */
@Test
public void testGetPortStatistics() {
    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);
    // test the getPortStatistics() method
    assertEquals("The port statistics set size did not match.", 0, deviceService.getPortStatistics(DID1).size());
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) DeviceService(org.onosproject.net.device.DeviceService) Test(org.junit.Test)

Example 35 with VirtualNetwork

use of org.onosproject.incubator.net.virtual.VirtualNetwork in project onos by opennetworkinglab.

the class VirtualNetworkDeviceManagerTest method testGetPortsStatisticsByNullId.

/**
 * Tests querying the port statistics of a device by null device identifier.
 */
@Test(expected = NullPointerException.class)
public void testGetPortsStatisticsByNullId() {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
    DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class);
    // test the getPortStatistics() method using a null device identifier
    deviceService.getPortStatistics(null);
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) DeviceService(org.onosproject.net.device.DeviceService) Test(org.junit.Test)

Aggregations

VirtualNetwork (org.onosproject.incubator.net.virtual.VirtualNetwork)98 Test (org.junit.Test)82 VirtualDevice (org.onosproject.incubator.net.virtual.VirtualDevice)38 DefaultVirtualNetwork (org.onosproject.incubator.net.virtual.DefaultVirtualNetwork)24 ConnectPoint (org.onosproject.net.ConnectPoint)24 TopologyService (org.onosproject.net.topology.TopologyService)24 Topology (org.onosproject.net.topology.Topology)23 DeviceService (org.onosproject.net.device.DeviceService)15 VirtualLink (org.onosproject.incubator.net.virtual.VirtualLink)12 DisjointPath (org.onosproject.net.DisjointPath)11 LinkService (org.onosproject.net.link.LinkService)10 ArrayList (java.util.ArrayList)8 HostService (org.onosproject.net.host.HostService)8 TenantId (org.onosproject.net.TenantId)7 Path (org.onosproject.net.Path)6 PathService (org.onosproject.net.topology.PathService)5 TopologyCluster (org.onosproject.net.topology.TopologyCluster)5 VirtualHost (org.onosproject.incubator.net.virtual.VirtualHost)4 VirtualPort (org.onosproject.incubator.net.virtual.VirtualPort)4 Link (org.onosproject.net.Link)4