Search in sources :

Example 16 with TopologyCluster

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

the class VirtualNetworkTopologyManagerTest method testGetClusterDevicesUsingNullCluster.

/**
 * Test getClusterDevices() methods with a null cluster.
 */
@Test(expected = NullPointerException.class)
public void testGetClusterDevicesUsingNullCluster() {
    VirtualNetwork virtualNetwork = setupVirtualNetworkTopology();
    TopologyService topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
    Topology topology = topologyService.currentTopology();
    Set<TopologyCluster> clusters = topologyService.getClusters(topology);
    // test the getClusterDevices() method using a null cluster.
    Object[] objects = clusters.stream().toArray();
    assertNotNull("The cluster should not be null.", objects);
    Set<DeviceId> clusterDevices = topologyService.getClusterDevices(topology, null);
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) DeviceId(org.onosproject.net.DeviceId) Topology(org.onosproject.net.topology.Topology) TopologyCluster(org.onosproject.net.topology.TopologyCluster) TopologyService(org.onosproject.net.topology.TopologyService) Test(org.junit.Test)

Example 17 with TopologyCluster

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

the class TopologyWebResource method getCluster.

/**
 * Gets details of a specific SCC.
 *
 * @param clusterId id of the cluster to query
 * @return 200 OK with topology cluster details
 * @onos.rsModel TopologyCluster
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("clusters/{id}")
public Response getCluster(@PathParam("id") int clusterId) {
    Topology topology = get(TopologyService.class).currentTopology();
    TopologyCluster cluster = getTopologyCluster(clusterId, topology);
    ObjectNode root = codec(TopologyCluster.class).encode(cluster, this);
    return ok(root).build();
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Topology(org.onosproject.net.topology.Topology) TopologyCluster(org.onosproject.net.topology.TopologyCluster) TopologyService(org.onosproject.net.topology.TopologyService) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 18 with TopologyCluster

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

the class TopologyWebResource method getClusters.

/**
 * Gets overview of topology SCCs.
 *
 * @return 200 OK with topology clusters overview
 * @onos.rsModel TopologyClusters
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("clusters")
public Response getClusters() {
    TopologyService service = get(TopologyService.class);
    Topology topology = service.currentTopology();
    Iterable<TopologyCluster> clusters = service.getClusters(topology);
    ObjectNode root = encodeArray(TopologyCluster.class, "clusters", clusters);
    return ok(root).build();
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Topology(org.onosproject.net.topology.Topology) TopologyCluster(org.onosproject.net.topology.TopologyCluster) TopologyService(org.onosproject.net.topology.TopologyService) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 19 with TopologyCluster

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

the class TopologyWebResource method getClusterLinks.

/**
 * Gets links in specific SCC.
 *
 * @param clusterId id of the cluster to query
 * @return 200 OK with topology cluster links
 * @onos.rsModel LinksGet
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("clusters/{id}/links")
public Response getClusterLinks(@PathParam("id") int clusterId) {
    Topology topology = get(TopologyService.class).currentTopology();
    TopologyCluster cluster = getTopologyCluster(clusterId, topology);
    List<Link> links = Lists.newArrayList(get(TopologyService.class).getClusterLinks(topology, cluster));
    return ok(encodeArray(Link.class, "links", links)).build();
}
Also used : Topology(org.onosproject.net.topology.Topology) TopologyCluster(org.onosproject.net.topology.TopologyCluster) Link(org.onosproject.net.Link) TopologyService(org.onosproject.net.topology.TopologyService) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

TopologyCluster (org.onosproject.net.topology.TopologyCluster)19 Topology (org.onosproject.net.topology.Topology)11 TopologyService (org.onosproject.net.topology.TopologyService)10 Test (org.junit.Test)7 DeviceId (org.onosproject.net.DeviceId)6 VirtualNetwork (org.onosproject.incubator.net.virtual.VirtualNetwork)5 Link (org.onosproject.net.Link)5 GET (javax.ws.rs.GET)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 ConnectPoint (org.onosproject.net.ConnectPoint)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 DefaultTopologyCluster (org.onosproject.net.topology.DefaultTopologyCluster)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 VirtualLink (org.onosproject.incubator.net.virtual.VirtualLink)2 DefaultTopologyVertex (org.onosproject.net.topology.DefaultTopologyVertex)2 TopologyEdge (org.onosproject.net.topology.TopologyEdge)2 TopologyVertex (org.onosproject.net.topology.TopologyVertex)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1