-
- # get shortest path
- try:
- # returns the first found shortest path
- # if all shortest paths are wanted, use: all_shortest_paths
- path = nx.shortest_path(self.DCNetwork_graph, src_sw, dst_sw, weight=kwargs.get('weight'))
- except:
- LOG.exception("No path could be found between {0} and {1} using src_sw={2} and dst_sw={3}".format(
- vnf_src_name, vnf_dst_name, src_sw, dst_sw))
- LOG.debug("Graph nodes: %r" % self.DCNetwork_graph.nodes())
- LOG.debug("Graph edges: %r" % self.DCNetwork_graph.edges())
- for e, v in self.DCNetwork_graph.edges():
- LOG.debug("%r" % self.DCNetwork_graph[e][v])
- return "No path could be found between {0} and {1}".format(vnf_src_name, vnf_dst_name)
+ path = kwargs.get('path')
+ if path is None:
+ # get shortest path
+ try:
+ # returns the first found shortest path
+ # if all shortest paths are wanted, use: all_shortest_paths
+ path = nx.shortest_path(self.DCNetwork_graph, src_sw, dst_sw, weight=kwargs.get('weight'))
+ except:
+ LOG.exception("No path could be found between {0} and {1} using src_sw={2} and dst_sw={3}".format(
+ vnf_src_name, vnf_dst_name, src_sw, dst_sw))
+ LOG.debug("Graph nodes: %r" % self.DCNetwork_graph.nodes())
+ LOG.debug("Graph edges: %r" % self.DCNetwork_graph.edges())
+ for e, v in self.DCNetwork_graph.edges():
+ LOG.debug("%r" % self.DCNetwork_graph[e][v])
+ return "No path could be found between {0} and {1}".format(vnf_src_name, vnf_dst_name)