Topology REST updates and cleanup:
* Added new REST call: /wm/onos/topology/all
It returns the whole topology: switches (and ports), links, devices:
{
"switches": [
...
],
"devices": [
...
],
"links": [
...
]
}
* Modified the path for existing topology REST calls to remove the
trailing "/json":
/wm/onos/topology/devices/json -> /wm/onos/topology/devices
/wm/onos/topology/links/json -> /wm/onos/topology/links
/wm/onos/topology/switches/json -> /wm/onos/topology/switches
* Added new ONOS CLI command "show topology all" to show the whole
topology
* Updated the ONOS CLI with the above REST calls path renaming
* Minor cleanup and bug fixes in the ONOS CLI
Change-Id: I96b85ca7a491671f049f30136618d00086384063
diff --git a/src/main/java/net/onrc/onos/core/topology/web/TopologyAllResource.java b/src/main/java/net/onrc/onos/core/topology/web/TopologyAllResource.java
new file mode 100644
index 0000000..700ca60
--- /dev/null
+++ b/src/main/java/net/onrc/onos/core/topology/web/TopologyAllResource.java
@@ -0,0 +1,33 @@
+package net.onrc.onos.core.topology.web;
+
+import net.onrc.onos.core.topology.ITopologyService;
+import net.onrc.onos.core.topology.Topology;
+
+import org.restlet.representation.Representation;
+import org.restlet.resource.Get;
+import org.restlet.resource.ServerResource;
+
+/**
+ * A class to access the network topology information.
+ */
+public class TopologyAllResource extends ServerResource {
+ /**
+ * Gets the network topology information.
+ *
+ * @return a Representation of the network topology.
+ */
+ @Get("json")
+ public Representation retrieve() {
+ ITopologyService topologyService =
+ (ITopologyService) getContext().getAttributes()
+ .get(ITopologyService.class.getCanonicalName());
+
+ Topology topology = topologyService.getTopology();
+ topology.acquireReadLock();
+ try {
+ return toRepresentation(topology, null);
+ } finally {
+ topology.releaseReadLock();
+ }
+ }
+}