Removed REST call
/wm/onos/topology/shortest-path/{src-dpid}/{dst-dpid}/json
because it is replaced by
/wm/onos/intent//path/switch/{src-dpid}/shortest-path/{dst-dpid}
Change-Id: Ia710b282cf98c96981646f642d415b209bee68c6
diff --git a/scripts/get_network_graph.py b/scripts/get_network_graph.py
index b91b569..4a85192 100755
--- a/scripts/get_network_graph.py
+++ b/scripts/get_network_graph.py
@@ -5,7 +5,6 @@
# Get Network Graph Information:
# - Switches
# - Links
-# - Shortest Path
#
import pprint
@@ -39,7 +38,6 @@
# @app.route("/wm/onos/topology/links/json ")
# @app.route("/wm/onos/topology/switches/json ")
-# @app.route("/wm/onos/topology/shortest-path/<src-dpid>/<dst-dpid>/json ")
# Sample output:
def print_parsed_result(parsedResult):
@@ -87,27 +85,6 @@
print_parsed_result(parsedResult)
-def get_network_shortest_path(src_dpid, dst_dpid):
- try:
- 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()
- debug("result %s" % result)
- if len(result) == 0:
- print "No Path found"
- return;
-
- # parsedResult = result
- parsedResult = json.loads(result, object_pairs_hook=collections.OrderedDict)
- parsedResult = json.dumps(parsedResult, indent=4)
- debug("parsed %s" % parsedResult)
- except:
- log_error("Controller IF has issue")
- exit(1)
-
- print_parsed_result(parsedResult)
-
if __name__ == "__main__":
usage_msg1 = "Usage:\n"
@@ -116,10 +93,8 @@
usage_msg4 = " all : Print all network elements\n"
usage_msg5 = " switches : Print all switches and ports\n"
usage_msg6 = " links : Print all links\n"
- usage_msg7 = " shortest-path <src-dpid> <dst-dpid> : Print shortest-path\n"
- usage_msg8 = " (links between <src-dpid> and <dst-dpid>)\n"
usage_msg = usage_msg1 + usage_msg2 + usage_msg3 + usage_msg4 + usage_msg5
- usage_msg = usage_msg + usage_msg6 + usage_msg7 + usage_msg8
+ usage_msg = usage_msg + usage_msg6
# Usage info
if len(sys.argv) > 1 and (sys.argv[1] == "-h" or sys.argv[1] == "--help"):
@@ -131,19 +106,12 @@
log_error(usage_msg)
exit(1)
- if (sys.argv[1] != "all" and sys.argv[1] != "switches" and sys.argv[1] != "links" and sys.argv[1] != "shortest-path"):
+ if (sys.argv[1] != "all" and sys.argv[1] != "switches" and sys.argv[1] != "links"):
log_error(usage_msg)
exit(1)
- if (sys.argv[1] == "shortest-path"):
- if len(sys.argv) < 4:
- log_error(usage_msg)
- exit(1)
-
# Do the work
if (sys.argv[1] == "all" or sys.argv[1] == "switches"):
get_network_switches()
if (sys.argv[1] == "all" or sys.argv[1] == "links"):
get_network_links()
- if (sys.argv[1] == "shortest-path"):
- get_network_shortest_path(sys.argv[2], sys.argv[3])
diff --git a/src/main/java/net/onrc/onos/core/topology/web/TopologyShortestPathResource.java b/src/main/java/net/onrc/onos/core/topology/web/TopologyShortestPathResource.java
deleted file mode 100644
index 29fd716..0000000
--- a/src/main/java/net/onrc/onos/core/topology/web/TopologyShortestPathResource.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package net.onrc.onos.core.topology.web;
-
-import java.io.IOException;
-import java.util.LinkedList;
-import java.util.List;
-
-import net.onrc.onos.core.intent.ConstrainedBFSTree;
-import net.onrc.onos.core.intent.Path;
-import net.onrc.onos.core.topology.ITopologyService;
-import net.onrc.onos.core.topology.Link;
-import net.onrc.onos.core.topology.LinkEvent;
-import net.onrc.onos.core.topology.Topology;
-import net.onrc.onos.core.topology.Switch;
-import net.onrc.onos.core.topology.serializers.LinkSerializer;
-import net.onrc.onos.core.util.Dpid;
-
-import org.codehaus.jackson.Version;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.module.SimpleModule;
-import org.restlet.resource.Get;
-import org.restlet.resource.ServerResource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class TopologyShortestPathResource extends ServerResource {
-
- private static final Logger log = LoggerFactory.getLogger(TopologyShortestPathResource.class);
-
- @Get("json")
- public String retrieve() {
- ITopologyService topologyService =
- (ITopologyService) getContext().getAttributes().
- get(ITopologyService.class.getCanonicalName());
-
- Topology topology = topologyService.getTopology();
-
- ObjectMapper mapper = new ObjectMapper();
- SimpleModule module = new SimpleModule("module", new Version(1, 0, 0, null));
- module.addSerializer(new LinkSerializer());
- mapper.registerModule(module);
-
- //
- // Fetch the attributes
- //
- String srcDpidStr = (String) getRequestAttributes().get("src-dpid");
- String dstDpidStr = (String) getRequestAttributes().get("dst-dpid");
- Dpid srcDpid = new Dpid(srcDpidStr);
- Dpid dstDpid = new Dpid(dstDpidStr);
- log.debug("Getting Shortest Path {}--{}", srcDpidStr, dstDpidStr);
-
- //
- // Do the Shortest Path computation and return the result: list of
- // links.
- //
- try {
- topology.acquireReadLock();
- Switch srcSwitch = topology.getSwitch(srcDpid.value());
- Switch dstSwitch = topology.getSwitch(dstDpid.value());
- if ((srcSwitch == null) || (dstSwitch == null)) {
- return "";
- }
- ConstrainedBFSTree bfsTree = new ConstrainedBFSTree(srcSwitch);
- Path path = bfsTree.getPath(dstSwitch);
- List<Link> links = new LinkedList<>();
- for (LinkEvent linkEvent : path) {
- Link link = topology.getLink(linkEvent.getSrc().getDpid(),
- linkEvent.getSrc().getNumber(),
- linkEvent.getDst().getDpid(),
- linkEvent.getDst().getNumber());
- if (link == null) {
- return "";
- }
- links.add(link);
- }
- return mapper.writeValueAsString(links);
- } catch (IOException e) {
- log.error("Error writing Shortest Path to JSON", e);
- return "";
- } finally {
- topology.releaseReadLock();
- }
- }
-}
diff --git a/src/main/java/net/onrc/onos/core/topology/web/TopologyWebRoutable.java b/src/main/java/net/onrc/onos/core/topology/web/TopologyWebRoutable.java
index 9e5dabe..0959ca6 100644
--- a/src/main/java/net/onrc/onos/core/topology/web/TopologyWebRoutable.java
+++ b/src/main/java/net/onrc/onos/core/topology/web/TopologyWebRoutable.java
@@ -21,8 +21,6 @@
router.attach("/devices", TopologyDevicesResource.class);
router.attach("/links", TopologyLinksResource.class);
router.attach("/switches", TopologySwitchesResource.class);
- // TODO: Move the Shortest Path REST API to the Intent framework
- router.attach("/shortest-path/{src-dpid}/{dst-dpid}/json", TopologyShortestPathResource.class);
return router;
}