X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FNAT.py;h=485cd53e71aae627da079afebee088bdf8f76cd1;hp=d0e01c7f84505afabe043ae03390b56a212c01fc;hb=3d279e4d68bbd94024bf739e71c872f18822a65d;hpb=954e51613f8dbd4f2fa4a7c2cf7c066176bee963 diff --git a/resources/libraries/python/NAT.py b/resources/libraries/python/NAT.py index d0e01c7f84..485cd53e71 100644 --- a/resources/libraries/python/NAT.py +++ b/resources/libraries/python/NAT.py @@ -43,28 +43,33 @@ class NATUtil(object): data = [] # lines[0,1] are table and column headers for line in lines[2::]: + # Ignore extra data after NAT table + if "snat_static_mapping_dump error: Misc" in line or "vat#" in line: + continue items = line.split(" ") while "" in items: items.remove("") if len(items) == 0: continue - elif len(items) == 3: + elif len(items) == 4: # no ports were returned data.append({ "local_address": items[0], "remote_address": items[1], - "vrf": items[2] + "vrf": items[2], + "protocol": items[3] }) - elif len(items) == 5: + elif len(items) == 6: data.append({ "local_address": items[0], "local_port": items[1], "remote_address": items[2], "remote_port": items[3], - "vrf": items[4] + "vrf": items[4], + "protocol": items[5] }) else: - raise RuntimeError("Unexpected output from span_mapping_dump.") + raise RuntimeError("Unexpected output from snat_mapping_dump.") return data @@ -90,8 +95,9 @@ class NATUtil(object): data = [] for line in lines: items = line.split(" ") - while "" in items: - items.remove("") + for trash in ("", "vat#"): + while trash in items: + items.remove(trash) if len(items) == 0: continue elif len(items) == 3: @@ -102,6 +108,6 @@ class NATUtil(object): }) else: raise RuntimeError( - "Unexpected output from span_interface_dump.") + "Unexpected output from snat_interface_dump.") return data