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);
}
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();
}
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();
}
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();
}
Aggregations