Search in sources :

Example 1 with DisjointPath

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;
}
Also used : DisjointPath(org.onosproject.net.DisjointPath)

Example 2 with DisjointPath

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());
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) Path(org.onosproject.net.Path) DisjointPath(org.onosproject.net.DisjointPath) PathService(org.onosproject.net.topology.PathService) DisjointPath(org.onosproject.net.DisjointPath) Test(org.junit.Test)

Example 3 with DisjointPath

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());
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) LinkWeigherAdapter(org.onosproject.net.topology.LinkWeigherAdapter) LinkWeigher(org.onosproject.net.topology.LinkWeigher) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) Topology(org.onosproject.net.topology.Topology) DisjointPath(org.onosproject.net.DisjointPath) TopologyService(org.onosproject.net.topology.TopologyService) Test(org.junit.Test)

Example 4 with DisjointPath

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);
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) Topology(org.onosproject.net.topology.Topology) DisjointPath(org.onosproject.net.DisjointPath) TopologyService(org.onosproject.net.topology.TopologyService) Test(org.junit.Test)

Example 5 with DisjointPath

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()));
            }
        }
    }
}
Also used : Path(org.onosproject.net.Path) DisjointPath(org.onosproject.net.DisjointPath) DeviceId(org.onosproject.net.DeviceId) DeviceService(org.onosproject.net.device.DeviceService) DisjointPath(org.onosproject.net.DisjointPath)

Aggregations

DisjointPath (org.onosproject.net.DisjointPath)19 Test (org.junit.Test)7 VirtualNetwork (org.onosproject.incubator.net.virtual.VirtualNetwork)7 Path (org.onosproject.net.Path)7 DefaultDisjointPath (org.onosproject.net.DefaultDisjointPath)6 VirtualDevice (org.onosproject.incubator.net.virtual.VirtualDevice)5 Topology (org.onosproject.net.topology.Topology)5 TopologyService (org.onosproject.net.topology.TopologyService)5 DefaultPath (org.onosproject.net.DefaultPath)4 DeviceId (org.onosproject.net.DeviceId)4 EdgeLink (org.onosproject.net.EdgeLink)3 Link (org.onosproject.net.Link)3 ImmutableSet (com.google.common.collect.ImmutableSet)2 ArrayList (java.util.ArrayList)2 GraphPathSearch (org.onlab.graph.GraphPathSearch)2 DefaultEdgeLink (org.onosproject.net.DefaultEdgeLink)2 Intent (org.onosproject.net.intent.Intent)2 LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)2 DefaultTopologyVertex (org.onosproject.net.topology.DefaultTopologyVertex)2 LinkWeigher (org.onosproject.net.topology.LinkWeigher)2