blob: 8e79639f8b3f9edc5aac99de7bb2c4f56100cce5 [file] [log] [blame]
Fahad Naeem Khan5b558f22014-10-16 10:35:20 -07001package net.onrc.onos.apps.segmentrouting.web;
2
3import java.util.HashMap;
4
5import net.floodlightcontroller.core.web.ControllerSwitchesResource;
6import net.onrc.onos.core.topology.ITopologyService;
7import net.onrc.onos.core.topology.MutableTopology;
8
9import org.restlet.resource.ResourceException;
10import org.restlet.resource.ServerResource;
11import org.restlet.representation.Representation;
12import org.restlet.resource.Get;
13import static net.onrc.onos.core.topology.web.TopologyResource.eval;
14/**
15 * Base class for return router statistics
16 *
17 */
18public class RouterStatisticsResource extends ServerResource {
19 /**
20 * Gets the switches and ports information from the network topology.
21 *
22 * @return a Representation of a Collection of switches from the network
23 * topology. Each switch contains the switch ports.
24 */
25 @Get("json")
26 public Representation retrieve() {
27 ITopologyService topologyService =
28 (ITopologyService) getContext().getAttributes()
29 .get(ITopologyService.class.getCanonicalName());
30
31 MutableTopology mutableTopology = topologyService.getTopology();
32 mutableTopology.acquireReadLock();
33 try {
34 return eval(toRepresentation(mutableTopology.getSwitches(), null));
35 } finally {
36 mutableTopology.releaseReadLock();
37 }
38 }
39
40
41
42}