X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=csit%2Flibraries%2FVsctlListParser.py;h=5b7c58246c62d988ca336fd1cd3ae6c6fee4a452;hb=115552e2120ca2e9aa2eb8ff18c339a8090589e1;hp=d5678c45164978c6395e6157485332e33802b686;hpb=864f7459205a24d4093342a5947807cea848f2ac;p=integration%2Ftest.git diff --git a/csit/libraries/VsctlListParser.py b/csit/libraries/VsctlListParser.py index d5678c4516..5b7c58246c 100644 --- a/csit/libraries/VsctlListParser.py +++ b/csit/libraries/VsctlListParser.py @@ -15,18 +15,18 @@ import traceback def _parse_stdout(stdout): - """ Transforms stdout to dict """ + """Transforms stdout to dict""" text = stdout.replace(" ", "") text = text.replace("\r", "") - pat = re.compile(r'(?P\w+):(?P.+)') + pat = re.compile(r"(?P\w+):(?P.+)") regroups = re.finditer(pat, text) outdict = {} for g in regroups: print((g.group())) - if g.group('key') == '_uuid': - cntl_uuid = g.group('value') + 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,36 +41,44 @@ def _postprocess_data(bridges, controllers): # replacing string value of is_connected key with boolean for key, cntl in cntls.items(): - if cntl['is_connected'] == 'false': - cntl['is_connected'] = False - elif cntl['is_connected'] == 'true': - cntl['is_connected'] = True + 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.items(): - brs[value['name'][1:-1]] = brs[key] + brs[value["name"][1:-1]] = brs[key] del brs[key] 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.items(): new_cntls = {} - for cnkey, cntl in bridge['controller'].items(): + 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