use of org.onosproject.net.DisjointPath in project onos by opennetworkinglab.
the class PathPainterTopovMessageHandler method buildDisjointPaths.
private ImmutableSet.Builder<Link> buildDisjointPaths(ImmutableSet.Builder<Link> pathBuilder) {
paths.forEach(path -> {
DisjointPath dp = (DisjointPath) path;
pathBuilder.addAll(dp.primary().links());
pathBuilder.addAll(dp.backup().links());
});
return pathBuilder;
}
use of org.onosproject.net.DisjointPath in project onos by opennetworkinglab.
the class VirtualNetworkPathManagerTest method testGetPathsOnEmptyVnet.
/**
* Tests getPaths(), getDisjointPaths()
* on an empty virtual network.
*/
@Test
public void testGetPathsOnEmptyVnet() {
VirtualNetwork vnet = setupEmptyVnet();
PathService pathService = manager.get(vnet.id(), PathService.class);
Set<Path> paths = pathService.getPaths(DID1, DID3);
assertEquals("incorrect path count", 0, paths.size());
Set<DisjointPath> disjointPaths = pathService.getDisjointPaths(DID1, DID3);
assertEquals("incorrect path count", 0, disjointPaths.size());
}
use of org.onosproject.net.DisjointPath 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.net.DisjointPath 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.net.DisjointPath in project onos by opennetworkinglab.
the class PathListCommand method doExecute.
@Override
protected void doExecute() {
init();
DeviceService deviceService = get(DeviceService.class);
DeviceId srcDid = deviceId(src);
if (deviceService.getDevice(srcDid) == null) {
print("Unknown device %s", src);
return;
}
DeviceId dstDid = deviceId(dst);
if (deviceService.getDevice(dstDid) == null) {
print("Unknown device %s", dst);
return;
}
Set<? extends Path> paths;
if (disjoint) {
paths = service.getDisjointPaths(topology, srcDid, dstDid);
} else {
paths = service.getPaths(topology, srcDid, dstDid);
}
if (outputJson()) {
print("%s", json(this, paths));
} else {
for (Path path : paths) {
print(pathString(path));
if (path instanceof DisjointPath) {
// print backup right after primary
print(pathString(((DisjointPath) path).backup()));
}
}
}
}
Aggregations