Fix a bug and cleanup the Topology REST API:
* Fix a bug in the base path:
/wm/onos -> /wm/onos/topology
If the base path is the top-level prefix /wm/onos, it hides all other
ONOS REST APIs that are added by a different module if at runtime
they are added after the NetworkGraphWebRoutable Restlet.
* Removed old REST APIs:
"/rc/switches/json"
"/rc/links/json"
"/rc/ports/json"
Those are same as the existing:
"/ds/switches/json"
"/ds/links/json"
"/ds/ports/json"
* Removed the "/ng" prefix for accessing the topology-related info
* Removed the old Topology API
Now the remaining and updated Topology REST API is:
// debug API to dump datastore content
/wm/onos/topology/ds/switches/json
/wm/onos/topology/ds/links/json
/wm/onos/topology/ds/ports/json
// Topology API
/wm/onos/topology/switches/json
/wm/onos/topology/links/json
// TODO: This one will be moved to the Intent framework REST API
/wm/onos/topology/shortest-path/{src-dpid}/{dst-dpid}/json
Change-Id: I367007413d9abdf28e0ce4ea0b78b2704f196dc7
diff --git a/scripts/get_network_graph.py b/scripts/get_network_graph.py
index c4b880d..b91b569 100755
--- a/scripts/get_network_graph.py
+++ b/scripts/get_network_graph.py
@@ -39,7 +39,7 @@
# @app.route("/wm/onos/topology/links/json ")
# @app.route("/wm/onos/topology/switches/json ")
-# @app.route("/wm/onos/ng/shortest-path/<src-dpid>/<dst-dpid>/json ")
+# @app.route("/wm/onos/topology/shortest-path/<src-dpid>/<dst-dpid>/json ")
# Sample output:
def print_parsed_result(parsedResult):
@@ -89,7 +89,7 @@
def get_network_shortest_path(src_dpid, dst_dpid):
try:
- command = "curl -s \"http://%s:%s/wm/onos/ng/shortest-path/%s/%s/json\"" % (ControllerIP, ControllerPort, src_dpid, dst_dpid)
+ command = "curl -s \"http://%s:%s/wm/onos/topology/shortest-path/%s/%s/json\"" % (ControllerIP, ControllerPort, src_dpid, dst_dpid)
debug("get_network_switches %s" % command)
result = os.popen(command).read()
diff --git a/src/main/java/net/onrc/onos/core/topology/web/NetworkGraphWebRoutable.java b/src/main/java/net/onrc/onos/core/topology/web/NetworkGraphWebRoutable.java
index 8f32f8a..b159fe6 100644
--- a/src/main/java/net/onrc/onos/core/topology/web/NetworkGraphWebRoutable.java
+++ b/src/main/java/net/onrc/onos/core/topology/web/NetworkGraphWebRoutable.java
@@ -11,30 +11,22 @@
@Override
public Restlet getRestlet(Context context) {
Router router = new Router(context);
- // leaving old path there for compatibility
- router.attach("/rc/switches/json", DatastoreSwitchesResource.class);
- router.attach("/rc/links/json", DatastoreLinksResource.class);
- router.attach("/rc/ports/json", DatastorePortsResource.class);
-
// debug API to dump datastore content
router.attach("/ds/switches/json", DatastoreSwitchesResource.class);
router.attach("/ds/links/json", DatastoreLinksResource.class);
router.attach("/ds/ports/json", DatastorePortsResource.class);
- router.attach("/ng/switches/json", NetworkGraphSwitchesResource.class);
- router.attach("/ng/links/json", NetworkGraphLinksResource.class);
- router.attach("/ng/shortest-path/{src-dpid}/{dst-dpid}/json", NetworkGraphShortestPathResource.class);
-
- // Old URLs for compatibility
- router.attach("/topology/switches/json", NetworkGraphSwitchesResource.class);
- router.attach("/topology/links/json", NetworkGraphLinksResource.class);
+ // Topology API
+ router.attach("/switches/json", NetworkGraphSwitchesResource.class);
+ router.attach("/links/json", NetworkGraphLinksResource.class);
+ // TODO: Move the Shortest Path REST API to the Intent framework
+ router.attach("/shortest-path/{src-dpid}/{dst-dpid}/json", NetworkGraphShortestPathResource.class);
return router;
}
@Override
public String basePath() {
- return "/wm/onos";
+ return "/wm/onos/topology";
}
-
}
diff --git a/web/topology_rest_napi.py b/web/topology_rest_napi.py
index e16c197..58c2de9 100755
--- a/web/topology_rest_napi.py
+++ b/web/topology_rest_napi.py
@@ -101,8 +101,7 @@
@app.route('/topology', methods=['GET'])
def topology_for_gui():
try:
- #url="http://%s:%s/wm/onos/topology/switches/all/json" % (RestIP, RestPort)
- url="http://%s:%s/wm/onos/ng/switches/json" % (RestIP, RestPort)
+ url="http://%s:%s/wm/onos/topology/switches/json" % (RestIP, RestPort)
(code, result) = get_json(url)
parsedResult = json.loads(result)
except:
@@ -145,8 +144,7 @@
switches[sw_id]['group'] = controllers.index(ctrl) + 1
try:
- #url = "http://%s:%s/wm/onos/topology/links/json" % (RestIP, RestPort)
- url = "http://%s:%s/wm/onos/ng/links/json" % (RestIP, RestPort)
+ url = "http://%s:%s/wm/onos/topology/links/json" % (RestIP, RestPort)
(code, result) = get_json(url)
parsedResult = json.loads(result)
except: