destpath = [] # Store shortest path info in an array orgId = [] destId = [] revDestId = [] orgWeight = [] destWeight = [] revDestWeight = [] ordNodeString = str(ordNode) ordNodeString = ordNodeString[offset:] ordNodeString = ordNodeString + endingString ordNodeGraph = topo.getNode(ordNodeString) # Compute paths forwards and backwards firstShort = DijkstraShortestPath(graph, ordNodeGraph, destNodeGraph) firstpath = firstShort.getPathEdgeList() firstweight = firstShort.getPathLength() secondShort = DijkstraShortestPath(graph, destNodeGraph, ordNodeGraph) secondpath = secondShort.getPathEdgeList() secondWeight = secondShort.getPathLength() # Skip paths that give us a NoneType, but record into nonetype dictionary and increment counter if firstpath == None: Nonetypecounter += 1 # Create entry if not in dictionary, else increment value nonetype[ordNodeString.encode("ascii")] = nonetype.get( ordNodeString, 0) + 1 nonetype[destNodeString.encode("ascii")] = nonetype.get( destNodeString, 0) + 1 continue
# Created by davidhua on 7/17/14. # # Run by calling viewtopo.py in netshell (No arguments); viewtopo.py [path] [source] [dest]; or viewtopo.py [bandwidth] [source] [dest]. topology = TopologyFactory.instance() topo = topology.retrieveTopologyProvider("localLayer2") command_args = sys.argv if len(command_args) == 2: graph = topo.getGraph(TopologyProvider.WeightType.TrafficEngineering) viewer = GraphViewer(graph) viewer.init() elif len(command_args) == 5: srcNode = topo.getNode(command_args[3] + "@es.net") dstNode = topo.getNode(command_args[4] + "@es.net") if command_args[2] == "path": graph = topo.getGraph(TopologyProvider.WeightType.TrafficEngineering) path = DijkstraShortestPath(graph, srcNode, dstNode) thispath = path.getPath() viewer = GraphViewer(thispath, graph) elif command_args[2] == "bandwidth": graph = topo.getGraph(TopologyProvider.WeightType.MaxBandwidth) md = ModifiedDijkstra(graph, srcNode, dstNode) maxBandwidth = md.getPath() viewer = GraphViewer(maxBandwidth, graph) viewer.init() else: sys.exit()