Search in sources :

Example 11 with TopologyService

use of org.onosproject.net.topology.TopologyService in project onos by opennetworkinglab.

the class VirtualNetworkManagerTest method setupVirtualNetworkTopology.

/**
 * Method to create the virtual network for {@code tenantIdValue} for further testing.
 */
private VirtualNetwork setupVirtualNetworkTopology(String tenantIdValue) {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue));
    VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue));
    VirtualDevice virtualDevice1 = manager.createVirtualDevice(virtualNetwork.id(), DID1);
    VirtualDevice virtualDevice2 = manager.createVirtualDevice(virtualNetwork.id(), DID2);
    VirtualDevice virtualDevice3 = manager.createVirtualDevice(virtualNetwork.id(), DID3);
    VirtualDevice virtualDevice4 = manager.createVirtualDevice(virtualNetwork.id(), DID4);
    VirtualDevice virtualDevice5 = manager.createVirtualDevice(virtualNetwork.id(), DID5);
    ConnectPoint cp1 = new ConnectPoint(virtualDevice1.id(), PortNumber.portNumber(1));
    manager.createVirtualPort(virtualNetwork.id(), virtualDevice1.id(), PortNumber.portNumber(1), cp1);
    ConnectPoint cp2 = new ConnectPoint(virtualDevice1.id(), PortNumber.portNumber(2));
    manager.createVirtualPort(virtualNetwork.id(), virtualDevice1.id(), PortNumber.portNumber(2), cp2);
    ConnectPoint cp3 = new ConnectPoint(virtualDevice2.id(), PortNumber.portNumber(3));
    manager.createVirtualPort(virtualNetwork.id(), virtualDevice2.id(), PortNumber.portNumber(3), cp3);
    ConnectPoint cp4 = new ConnectPoint(virtualDevice2.id(), PortNumber.portNumber(4));
    manager.createVirtualPort(virtualNetwork.id(), virtualDevice2.id(), PortNumber.portNumber(4), cp4);
    ConnectPoint cp5 = new ConnectPoint(virtualDevice3.id(), PortNumber.portNumber(5));
    manager.createVirtualPort(virtualNetwork.id(), virtualDevice3.id(), PortNumber.portNumber(5), cp5);
    cp6 = new ConnectPoint(virtualDevice3.id(), PortNumber.portNumber(6));
    manager.createVirtualPort(virtualNetwork.id(), virtualDevice3.id(), PortNumber.portNumber(6), cp6);
    cp7 = new ConnectPoint(virtualDevice4.id(), PortNumber.portNumber(7));
    manager.createVirtualPort(virtualNetwork.id(), virtualDevice4.id(), PortNumber.portNumber(7), cp7);
    ConnectPoint cp8 = new ConnectPoint(virtualDevice4.id(), PortNumber.portNumber(8));
    manager.createVirtualPort(virtualNetwork.id(), virtualDevice4.id(), PortNumber.portNumber(8), cp8);
    ConnectPoint cp9 = new ConnectPoint(virtualDevice5.id(), PortNumber.portNumber(9));
    manager.createVirtualPort(virtualNetwork.id(), virtualDevice5.id(), PortNumber.portNumber(9), cp9);
    VirtualLink link1 = manager.createVirtualLink(virtualNetwork.id(), cp1, cp3);
    virtualNetworkManagerStore.updateLink(link1, link1.tunnelId(), Link.State.ACTIVE);
    VirtualLink link2 = manager.createVirtualLink(virtualNetwork.id(), cp3, cp1);
    virtualNetworkManagerStore.updateLink(link2, link2.tunnelId(), Link.State.ACTIVE);
    VirtualLink link3 = manager.createVirtualLink(virtualNetwork.id(), cp4, cp5);
    virtualNetworkManagerStore.updateLink(link3, link3.tunnelId(), Link.State.ACTIVE);
    VirtualLink link4 = manager.createVirtualLink(virtualNetwork.id(), cp5, cp4);
    virtualNetworkManagerStore.updateLink(link4, link4.tunnelId(), Link.State.ACTIVE);
    VirtualLink link5 = manager.createVirtualLink(virtualNetwork.id(), cp8, cp9);
    virtualNetworkManagerStore.updateLink(link5, link5.tunnelId(), Link.State.ACTIVE);
    VirtualLink link6 = manager.createVirtualLink(virtualNetwork.id(), cp9, cp8);
    virtualNetworkManagerStore.updateLink(link6, link6.tunnelId(), Link.State.ACTIVE);
    topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
    topologyProvider = new DefaultVirtualNetworkProvider();
    try {
        TestUtils.setField(topologyProvider, "topologyService", topologyService);
    } catch (TestUtils.TestUtilsException e) {
        e.printStackTrace();
    }
    return virtualNetwork;
}
Also used : DefaultVirtualNetwork(org.onosproject.incubator.net.virtual.DefaultVirtualNetwork) VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) TestUtils(org.onlab.junit.TestUtils) DefaultVirtualNetworkProvider(org.onosproject.incubator.net.virtual.impl.provider.DefaultVirtualNetworkProvider) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) ConnectPoint(org.onosproject.net.ConnectPoint) VirtualLink(org.onosproject.incubator.net.virtual.VirtualLink) TopologyService(org.onosproject.net.topology.TopologyService)

Example 12 with TopologyService

use of org.onosproject.net.topology.TopologyService in project onos by opennetworkinglab.

the class VirtualNetworkTopologyManagerTest method testGetPathsUsingNullSrcDeviceId.

/**
 * Test getPaths() method using a null src device identifier.
 */
@Test(expected = NullPointerException.class)
public void testGetPathsUsingNullSrcDeviceId() {
    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 src device identifier.
    Set<Path> paths = topologyService.getPaths(topology, null, dstVirtualDevice.id());
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) Path(org.onosproject.net.Path) DisjointPath(org.onosproject.net.DisjointPath) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) Topology(org.onosproject.net.topology.Topology) TopologyService(org.onosproject.net.topology.TopologyService) Test(org.junit.Test)

Example 13 with TopologyService

use of org.onosproject.net.topology.TopologyService in project onos by opennetworkinglab.

the class VirtualNetworkTopologyManagerTest method testIsInfrastructure.

/**
 * Test isInfrastructure() method.
 */
@Test
public void testIsInfrastructure() {
    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(), DID4);
    ConnectPoint cp1 = new ConnectPoint(srcVirtualDevice.id(), PortNumber.portNumber(1));
    ConnectPoint cp2 = new ConnectPoint(dstVirtualDevice.id(), PortNumber.portNumber(2));
    // test the isInfrastructure() method.
    Boolean isInfrastructure = topologyService.isInfrastructure(topology, cp1);
    assertTrue("The connect point should be infrastructure.", isInfrastructure);
    isInfrastructure = topologyService.isInfrastructure(topology, cp2);
    assertFalse("The connect point should not be infrastructure.", isInfrastructure);
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) Topology(org.onosproject.net.topology.Topology) ConnectPoint(org.onosproject.net.ConnectPoint) TopologyService(org.onosproject.net.topology.TopologyService) Test(org.junit.Test)

Example 14 with TopologyService

use of org.onosproject.net.topology.TopologyService in project onos by opennetworkinglab.

the class VirtualNetworkTopologyManagerTest method testGetPaths.

/**
 * Test getPaths() and getPaths() by weight methods.
 */
@Test
public void testGetPaths() {
    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.
    Set<Path> paths = topologyService.getPaths(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 getPaths() by weight method.
    LinkWeigher weight = new LinkWeigherAdapter(1.0);
    Set<Path> paths1 = topologyService.getPaths(topology, srcVirtualDevice.id(), dstVirtualDevice.id(), weight);
    assertNotNull("The paths should not be null.", paths1);
    assertEquals("The paths size did not match.", 1, paths1.size());
    Path path = paths1.iterator().next();
    assertEquals("wrong path length", 1, path.links().size());
    assertEquals("wrong path cost", ScalarWeight.toWeight(1.0), path.weight());
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) Path(org.onosproject.net.Path) DisjointPath(org.onosproject.net.DisjointPath) 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) TopologyService(org.onosproject.net.topology.TopologyService) Test(org.junit.Test)

Example 15 with TopologyService

use of org.onosproject.net.topology.TopologyService in project onos by opennetworkinglab.

the class VirtualNetworkTopologyManagerTest method testCurrentTopology.

/**
 * Tests the currentTopology() method.
 */
@Test
public void testCurrentTopology() {
    VirtualNetwork virtualNetwork = setupVirtualNetworkTopology();
    TopologyService topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
    Topology topology = topologyService.currentTopology();
    assertNotNull("The topology should not be null.", topology);
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) Topology(org.onosproject.net.topology.Topology) TopologyService(org.onosproject.net.topology.TopologyService) Test(org.junit.Test)

Aggregations

TopologyService (org.onosproject.net.topology.TopologyService)30 Topology (org.onosproject.net.topology.Topology)25 VirtualNetwork (org.onosproject.incubator.net.virtual.VirtualNetwork)24 Test (org.junit.Test)23 VirtualDevice (org.onosproject.incubator.net.virtual.VirtualDevice)13 DisjointPath (org.onosproject.net.DisjointPath)9 TopologyCluster (org.onosproject.net.topology.TopologyCluster)8 VirtualLink (org.onosproject.incubator.net.virtual.VirtualLink)5 ConnectPoint (org.onosproject.net.ConnectPoint)4 Path (org.onosproject.net.Path)4 DeviceId (org.onosproject.net.DeviceId)3 Link (org.onosproject.net.Link)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 Before (org.junit.Before)2 TestServiceDirectory (org.onlab.osgi.TestServiceDirectory)2 LinkWeigher (org.onosproject.net.topology.LinkWeigher)2 LinkWeigherAdapter (org.onosproject.net.topology.LinkWeigherAdapter)2