use of org.onosproject.net.topology.TopologyCluster 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);
}
use of org.onosproject.net.topology.TopologyCluster in project onos by opennetworkinglab.
the class DefaultTopologyTest method clusterRelated.
@Test
public void clusterRelated() {
Set<TopologyCluster> clusters = dt.getClusters();
assertEquals("incorrect cluster count", 2, clusters.size());
TopologyCluster c = dt.getCluster(D1);
Set<DeviceId> devs = dt.getClusterDevices(c);
assertEquals("incorrect cluster device count", 4, devs.size());
assertTrue("cluster should contain D2", devs.contains(D2));
assertFalse("cluster should not contain D5", devs.contains(D5));
}
use of org.onosproject.net.topology.TopologyCluster 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();
}
use of org.onosproject.net.topology.TopologyCluster in project onos by opennetworkinglab.
the class ClusterIdCompleter method complete.
@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
// Delegate string completer
StringsCompleter delegate = new StringsCompleter();
// Fetch our service and feed it's offerings to the string completer
TopologyService service = AbstractShellCommand.get(TopologyService.class);
Topology topology = service.currentTopology();
SortedSet<String> strings = delegate.getStrings();
for (TopologyCluster cluster : service.getClusters(topology)) {
strings.add(Integer.toString(cluster.id().index()));
}
// Now let the completer do the work for figuring out what to offer.
return delegate.complete(session, commandLine, candidates);
}
use of org.onosproject.net.topology.TopologyCluster in project onos by opennetworkinglab.
the class ClusterLinksCommand method doExecute.
@Override
protected void doExecute() {
int cid = Integer.parseInt(id);
init();
TopologyCluster cluster = service.getCluster(topology, clusterId(cid));
if (cluster == null) {
error("No such cluster %s", cid);
} else if (outputJson()) {
print("%s", json(this, service.getClusterLinks(topology, cluster)));
} else {
for (Link link : service.getClusterLinks(topology, cluster)) {
print(linkString(link));
}
}
}
Aggregations