Freeze upstream versions
[netvirt.git] / resources / commons / showOvsdbMdsal.py
index 05102cb7d6016a9f20a0db575c6b89ba1fdc5041..3d566eb22fb7747feee4107cd6cbf7cd6ab934c6 100755 (executable)
@@ -139,6 +139,16 @@ class OvsdbNode:
 
 # ======================================================================
 
+def make_it_a_string(param):
+    result = ""
+    try:
+        result = str( param )
+    except:
+        pass
+    return result
+
+# ======================================================================
+
 def printError(msg):
     sys.stderr.write(msg)
 
@@ -345,8 +355,8 @@ def parseTopologyJsonNodeOvsdb(indent, mdsalTreeType, topologyId, nodeIndex, nod
     connectionInfoRaw = node.get('ovsdb:connection-info')
     connectionInfo = {}
     if type(connectionInfoRaw) is dict:
-        connectionInfo['inetMgr'] = connectionInfoRaw.get('local-ip') + ':' + str( connectionInfoRaw.get('local-port') )
-        connectionInfo['inetNode'] = connectionInfoRaw.get('remote-ip') + ':' + str( connectionInfoRaw.get('remote-port') )
+        connectionInfo['inetMgr'] = make_it_a_string(connectionInfoRaw.get('local-ip')) + ':' + make_it_a_string(connectionInfoRaw.get('local-port'))
+        connectionInfo['inetNode'] = make_it_a_string(connectionInfoRaw.get('remote-ip')) + ':' + make_it_a_string(connectionInfoRaw.get('remote-port'))
     otherConfigsRaw = node.get('ovsdb:openvswitch-other-configs')
     otherLocalIp = ''
     if type(otherConfigsRaw) is list:
@@ -459,13 +469,10 @@ def showPrettyNamesMap():
     prtLn('aliasMap:', 0)
     resultMap = {}
     for bridge in state.bridgeNodes.values():
-        resultMap[ bridge.alias ] = bridge.getOpenflowName()
-
-    resultMapKeys = resultMap.keys()
-    resultMapKeys.sort()
+        resultMap[ bridge.alias ] = '{0: <25} {1: <7} {2}'.format(bridge.getOpenflowName(), bridge.name, bridge.dpId)
 
-    for resultMapKey in resultMapKeys:
-        prtLn('{0}{1: <10} -> {2}'.format(spc, resultMapKey, resultMap[resultMapKey]), 0)
+    for resultMapKey in sorted(resultMap):
+        prtLn('{0}{1: <10} ->  {2}'.format(spc, resultMapKey, resultMap[resultMapKey]), 0)
     prtLn('', 0)
 
 # --