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;
}
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;
}
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);
}
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());
}
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);
}
Aggregations