Search in sources :

Example 36 with Topology

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

the class VirtualNetworkTopologyManagerTest method testGetGraph.

/**
 * Test getGraph() method.
 */
@Test
public void testGetGraph() {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
    TopologyService topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
    Topology topology = topologyService.currentTopology();
    // test the getGraph() method.
    assertNotNull("The graph should not be null.", topologyService.getGraph(topology));
}
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 37 with Topology

use of org.onosproject.net.topology.Topology 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 38 with Topology

use of org.onosproject.net.topology.Topology 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 39 with Topology

use of org.onosproject.net.topology.Topology 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 40 with Topology

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

the class TopologyWebResource method getConnectPointBroadcast.

/**
 * Tests if a connect point is in broadcast set.
 *
 * @param connectPointString deviceid:portnumber
 * @return 200 OK with JSON representation of true if the connect point is
 * broadcast, false otherwise
 * @onos.rsModel TopologyBroadcast
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("broadcast/{connectPoint}")
public Response getConnectPointBroadcast(@PathParam("connectPoint") String connectPointString) {
    Topology topology = get(TopologyService.class).currentTopology();
    DeviceId deviceId = DeviceId.deviceId(getDeviceId(connectPointString));
    nullIsNotFound(get(DeviceService.class).getDevice(deviceId), "Device not found " + connectPointString);
    PortNumber portNumber = PortNumber.portNumber(getPortNumber(connectPointString));
    nullIsNotFound(get(DeviceService.class).getPort(deviceId, portNumber), "Port not found " + connectPointString);
    ConnectPoint connectPoint = new ConnectPoint(deviceId, portNumber);
    boolean isBroadcast = get(TopologyService.class).isBroadcastPoint(topology, connectPoint);
    return ok(mapper().createObjectNode().put("broadcast", isBroadcast)).build();
}
Also used : DeviceId(org.onosproject.net.DeviceId) Topology(org.onosproject.net.topology.Topology) PortNumber(org.onosproject.net.PortNumber) ConnectPoint(org.onosproject.net.ConnectPoint) TopologyService(org.onosproject.net.topology.TopologyService) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

Topology (org.onosproject.net.topology.Topology)46 TopologyService (org.onosproject.net.topology.TopologyService)30 Test (org.junit.Test)29 VirtualNetwork (org.onosproject.incubator.net.virtual.VirtualNetwork)23 VirtualDevice (org.onosproject.incubator.net.virtual.VirtualDevice)12 TopologyCluster (org.onosproject.net.topology.TopologyCluster)11 DisjointPath (org.onosproject.net.DisjointPath)9 Path (org.onosproject.net.Path)9 ConnectPoint (org.onosproject.net.ConnectPoint)8 GET (javax.ws.rs.GET)7 Produces (javax.ws.rs.Produces)7 Link (org.onosproject.net.Link)7 Path (javax.ws.rs.Path)6 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)5 VirtualLink (org.onosproject.incubator.net.virtual.VirtualLink)5 DeviceId (org.onosproject.net.DeviceId)5 LinkWeigher (org.onosproject.net.topology.LinkWeigher)5 Event (org.onosproject.event.Event)3 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 ClusterEvent (org.onosproject.cluster.ClusterEvent)2