use of org.onosproject.incubator.net.virtual.VirtualNetwork in project onos by opennetworkinglab.
the class VirtualNetworkTopologyManagerTest method testGetPathsUsingNullWeight.
/**
* Test getPaths() method using a null weight.
*/
@Test(expected = NullPointerException.class)
public void testGetPathsUsingNullWeight() {
VirtualNetwork virtualNetwork = setupVirtualNetworkTopology();
TopologyService topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
Topology topology = topologyService.currentTopology();
VirtualDevice srcVirtualDevice = getVirtualDevice(virtualNetwork.id(), DID1);
VirtualDevice dstVirtualDevice = getVirtualDevice(virtualNetwork.id(), DID2);
// test the getPaths() method using a null weight.
Set<Path> paths = topologyService.getPaths(topology, srcVirtualDevice.id(), dstVirtualDevice.id(), (LinkWeigher) null);
}
use of org.onosproject.incubator.net.virtual.VirtualNetwork in project onos by opennetworkinglab.
the class VirtualNetworkTopologyManagerTest method testGetDisjointPaths.
/**
* Test getDisjointPaths() methods.
*/
@Test
public void testGetDisjointPaths() {
VirtualNetwork virtualNetwork = setupVirtualNetworkTopology();
TopologyService topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
Topology topology = topologyService.currentTopology();
VirtualDevice srcVirtualDevice = getVirtualDevice(virtualNetwork.id(), DID1);
VirtualDevice dstVirtualDevice = getVirtualDevice(virtualNetwork.id(), DID2);
// test the getDisjointPaths() method.
Set<DisjointPath> paths = topologyService.getDisjointPaths(topology, srcVirtualDevice.id(), dstVirtualDevice.id());
assertNotNull("The paths should not be null.", paths);
assertEquals("The paths size did not match.", 1, paths.size());
// test the getDisjointPaths() method using a weight.
LinkWeigher weight = new LinkWeigherAdapter(1.0);
Set<DisjointPath> paths1 = topologyService.getDisjointPaths(topology, srcVirtualDevice.id(), dstVirtualDevice.id(), weight);
assertNotNull("The paths should not be null.", paths1);
assertEquals("The paths size did not match.", 1, paths1.size());
}
use of org.onosproject.incubator.net.virtual.VirtualNetwork in project onos by opennetworkinglab.
the class VirtualNetworkTopologyManagerTest method testGetDisjointPathsUsingNullDstDeviceId.
/**
* Test getDisjointPaths() methods using a null dst device identifier.
*/
@Test(expected = NullPointerException.class)
public void testGetDisjointPathsUsingNullDstDeviceId() {
VirtualNetwork virtualNetwork = setupVirtualNetworkTopology();
TopologyService topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
Topology topology = topologyService.currentTopology();
VirtualDevice srcVirtualDevice = getVirtualDevice(virtualNetwork.id(), DID1);
VirtualDevice dstVirtualDevice = getVirtualDevice(virtualNetwork.id(), DID2);
// test the getDisjointPaths() method using a null dst device identifier.
Set<DisjointPath> paths = topologyService.getDisjointPaths(topology, srcVirtualDevice.id(), null);
}
use of org.onosproject.incubator.net.virtual.VirtualNetwork in project onos by opennetworkinglab.
the class VirtualNetworkTopologyManagerTest method testGetClusters.
/**
* Test getClusters() method.
*/
@Test
public void testGetClusters() {
VirtualNetwork virtualNetwork = setupVirtualNetworkTopology();
TopologyService topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
Topology topology = topologyService.currentTopology();
// test the getClusters() method.
assertNotNull("The clusters should not be null.", topologyService.getClusters(topology));
assertEquals("The clusters size did not match.", 2, topologyService.getClusters(topology).size());
}
use of org.onosproject.incubator.net.virtual.VirtualNetwork in project onos by opennetworkinglab.
the class DistributedVirtualNetworkStore method removeNetwork.
@Override
public void removeNetwork(NetworkId networkId) {
// Make sure that the virtual network exists before attempting to remove it.
checkState(networkExists(networkId), "The network does not exist.");
// Remove all the devices of this network
Set<VirtualDevice> deviceSet = getDevices(networkId);
if (deviceSet != null) {
deviceSet.forEach(virtualDevice -> removeDevice(networkId, virtualDevice.id()));
}
// TODO update both maps in one transaction.
VirtualNetwork virtualNetwork = networkIdVirtualNetworkMap.remove(networkId);
if (virtualNetwork == null) {
return;
}
TenantId tenantId = virtualNetwork.tenantId();
Set<NetworkId> networkIdSet = new HashSet<>();
tenantIdNetworkIdSetMap.get(tenantId).forEach(networkId1 -> {
if (networkId1.id().equals(networkId.id())) {
networkIdSet.add(networkId1);
}
});
tenantIdNetworkIdSetMap.compute(virtualNetwork.tenantId(), (id, existingNetworkIds) -> {
if (existingNetworkIds == null || existingNetworkIds.isEmpty()) {
return new HashSet<>();
} else {
return new HashSet<>(Sets.difference(existingNetworkIds, networkIdSet));
}
});
}
Aggregations