Update certificates for OpenFlow TLS connection
[integration/test.git] / csit / libraries / VsctlListParser.py
index 136f109a3d09f0d36709497fcd3bf40ff0c70911..509eed6d2c62ecb997dec713039d396450b90dc9 100644 (file)
@@ -11,7 +11,6 @@ Created: 2016-04-04
 
 import re
 import copy
-import sys
 import traceback
 
 
@@ -19,15 +18,15 @@ def _parse_stdout(stdout):
     """ Transforms stdout to dict """
     text = stdout.replace(" ", "")
     text = text.replace("\r", "")
-    pat = re.compile(r'(?P<key>\w+):(?P<value>.+)')
+    pat = re.compile(r"(?P<key>\w+):(?P<value>.+)")
     regroups = re.finditer(pat, text)
     outdict = {}
     for g in regroups:
-        print g.group()
-        if g.group('key') == '_uuid':
-            cntl_uuid = g.group('value')
+        print((g.group()))
+        if g.group("key") == "_uuid":
+            cntl_uuid = g.group("value")
             outdict[cntl_uuid] = {}
-        outdict[cntl_uuid][g.group('key')] = g.group('value')
+        outdict[cntl_uuid][g.group("key")] = g.group("value")
     return outdict
 
 
@@ -41,37 +40,45 @@ def _postprocess_data(bridges, controllers):
     cntls = copy.deepcopy(controllers)
 
     # replacing string value of is_connected key with boolean
-    for key, cntl in cntls.iteritems():
-        if cntl['is_connected'] == 'false':
-            cntl['is_connected'] = False
-        elif cntl['is_connected'] == 'true':
-            cntl['is_connected'] = True
+    for key, cntl in cntls.items():
+        if cntl["is_connected"] == "false":
+            cntl["is_connected"] = False
+        elif cntl["is_connected"] == "true":
+            cntl["is_connected"] = True
         else:
-            cntl['is_connected'] = None
+            cntl["is_connected"] = None
 
     # replacing keys with the same values
-    for key, value in bridges.iteritems():
-        brs[value['name'][1:-1]] = brs[key]
+    for key, value in bridges.items():
+        brs[value["name"][1:-1]] = brs[key]
         del brs[key]
 
-    for key, value in brs.iteritems():
+    for key, value in brs.items():
         # replace string with references with dict of controllers
-        ctl_refs = value['controller'][1:-1].split(',')
-        value['controller'] = {}
+        ctl_refs = value["controller"][1:-1].split(",")
+        value["controller"] = {}
         for ctl_ref in ctl_refs:
-            if ctl_ref is not '':
-                value['controller'][ctl_ref] = cntls[ctl_ref]
+            if ctl_ref is not "":
+                value["controller"][ctl_ref] = cntls[ctl_ref]
 
-    for brkey, bridge in brs.iteritems():
+    for brkey, bridge in brs.items():
         new_cntls = {}
-        for cnkey, cntl in bridge['controller'].iteritems():
+        for cnkey, cntl in bridge["controller"].items():
             # port 6654 is set by OvsMAnager.robot to disconnect from controller
-            if '6653' in cntl['target'] or '6633' in cntl['target'] or '6654' in cntl['target']:
-                new_key = cntl['target'].split(":")[1]     # getting middle from "tcp:ip:6653"
+            if (
+                "6653" in cntl["target"]
+                or "6633" in cntl["target"]
+                or "6654" in cntl["target"]
+            ):
+                new_key = cntl["target"].split(":")[
+                    1
+                ]  # getting middle from "tcp:ip:6653"
             else:
-                new_key = cntl['target'][1:-1]  # getting string without quotes "ptcp:6638"
+                new_key = cntl["target"][
+                    1:-1
+                ]  # getting string without quotes "ptcp:6638"
             new_cntls[new_key] = cntl
-        bridge['controller'] = new_cntls
+        bridge["controller"] = new_cntls
 
     return brs