Search in sources :

Example 6 with TopologyCluster

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);
}
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 7 with TopologyCluster

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));
}
Also used : DeviceId(org.onosproject.net.DeviceId) TopologyCluster(org.onosproject.net.topology.TopologyCluster) Test(org.junit.Test)

Example 8 with TopologyCluster

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();
}
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 9 with TopologyCluster

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);
}
Also used : StringsCompleter(org.apache.karaf.shell.support.completers.StringsCompleter) Topology(org.onosproject.net.topology.Topology) TopologyCluster(org.onosproject.net.topology.TopologyCluster) TopologyService(org.onosproject.net.topology.TopologyService)

Example 10 with TopologyCluster

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));
        }
    }
}
Also used : TopologyCluster(org.onosproject.net.topology.TopologyCluster) Link(org.onosproject.net.Link)

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