Search in sources :

Example 6 with TopologyService

use of org.onosproject.net.topology.TopologyService 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());
}
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)

Example 7 with TopologyService

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

the class VirtualNetworkTopologyManagerTest method testGetClusterUsingNullClusterId.

/**
 * Test getCluster() method using a null cluster identifier.
 */
@Test(expected = NullPointerException.class)
public void testGetClusterUsingNullClusterId() {
    VirtualNetwork virtualNetwork = setupVirtualNetworkTopology();
    TopologyService topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
    Topology topology = topologyService.currentTopology();
    Set<TopologyCluster> clusters = topologyService.getClusters(topology);
    TopologyCluster cluster = clusters.stream().findFirst().get();
    // test the getCluster() method with a null cluster identifier
    TopologyCluster cluster1 = topologyService.getCluster(topology, null);
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) Topology(org.onosproject.net.topology.Topology) TopologyCluster(org.onosproject.net.topology.TopologyCluster) TopologyService(org.onosproject.net.topology.TopologyService) Test(org.junit.Test)

Example 8 with TopologyService

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

the class TopologyResourceTest method setUpTest.

/**
 * Initializes the test harness.
 */
@Before
public void setUpTest() {
    TopologyService topologyService = new MockTopologyService();
    DeviceService mockDeviceService = new MockDeviceService();
    CodecManager codecService = new CodecManager();
    codecService.activate();
    ServiceDirectory testDirectory = new TestServiceDirectory().add(DeviceService.class, mockDeviceService).add(TopologyService.class, topologyService).add(CodecService.class, codecService);
    setServiceDirectory(testDirectory);
}
Also used : ServiceDirectory(org.onlab.osgi.ServiceDirectory) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) DeviceService(org.onosproject.net.device.DeviceService) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) CodecManager(org.onosproject.codec.impl.CodecManager) TopologyService(org.onosproject.net.topology.TopologyService) Before(org.junit.Before)

Example 9 with TopologyService

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

the class TopologyWebResource method getClusterDevices.

/**
 * Gets devices in a specific SCC.
 *
 * @param clusterId id of the cluster to query
 * @return 200 OK with topology cluster devices
 * @onos.rsModel TopologyClustersDevices
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("clusters/{id}/devices")
public Response getClusterDevices(@PathParam("id") int clusterId) {
    TopologyService service = get(TopologyService.class);
    Topology topology = service.currentTopology();
    TopologyCluster cluster = getTopologyCluster(clusterId, topology);
    List<DeviceId> deviceIds = Lists.newArrayList(service.getClusterDevices(topology, cluster));
    ObjectNode root = mapper().createObjectNode();
    ArrayNode devicesNode = root.putArray("devices");
    deviceIds.forEach(id -> devicesNode.add(id.toString()));
    return ok(root).build();
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) DeviceId(org.onosproject.net.DeviceId) Topology(org.onosproject.net.topology.Topology) TopologyCluster(org.onosproject.net.topology.TopologyCluster) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) TopologyService(org.onosproject.net.topology.TopologyService) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 10 with TopologyService

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

the class PathPainterTopovMessageHandler method init.

// ===============-=-=-=-=-=-======================-=-=-=-=-=-=-===========
@Override
public void init(UiConnection connection, ServiceDirectory directory) {
    super.init(connection, directory);
    pathService = directory.get(PathService.class);
    topologyService = directory.get(TopologyService.class);
    linkData = new GeoDistanceLinkWeight(directory.get(DeviceService.class));
    addListeners();
}
Also used : GeoDistanceLinkWeight(org.onosproject.net.topology.GeoDistanceLinkWeight) PathService(org.onosproject.net.topology.PathService) TopologyService(org.onosproject.net.topology.TopologyService)

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