Skip to content

Commit

Permalink
Fixing python porting errors in fdbshow, natshow and nbrshow (sonic-n…
Browse files Browse the repository at this point in the history
…et#1280)

I fixed python porting errors in fdbshow, natshow and nbrshow scripts by removing 'b' from strings of the form b"xxxxx"

Co-authored-by: Madhan Babu <madhan@10.212.221.1>
  • Loading branch information
madhanmellanox and Madhan Babu authored Dec 2, 2020
1 parent a2728cb commit 3e2bfa8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions scripts/fdbshow
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ class FdbShow(object):
continue

ent = self.db.get_all('ASIC_DB', s, blocking=True)
br_port_id = ent[b"SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID"][oid_pfx:]
ent_type = ent[b"SAI_FDB_ENTRY_ATTR_TYPE"]
br_port_id = ent["SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID"][oid_pfx:]
ent_type = ent["SAI_FDB_ENTRY_ATTR_TYPE"]
fdb_type = ['Dynamic','Static'][ent_type == "SAI_FDB_ENTRY_TYPE_STATIC"]
if br_port_id not in self.if_br_oid_map:
continue
Expand Down
16 changes: 8 additions & 8 deletions scripts/natshow
Original file line number Diff line number Diff line change
Expand Up @@ -139,30 +139,30 @@ class NatShow(object):
nat_type = nat['nat_type']

if nat_type == "SAI_NAT_TYPE_DESTINATION_NAT":
translated_dst_ip = ent[b"SAI_NAT_ENTRY_ATTR_DST_IP"]
translated_dst_ip = ent["SAI_NAT_ENTRY_ATTR_DST_IP"]
if "SAI_NAT_ENTRY_ATTR_L4_DST_PORT" in ent:
translated_dst_port = ent[b"SAI_NAT_ENTRY_ATTR_L4_DST_PORT"]
translated_dst_port = ent["SAI_NAT_ENTRY_ATTR_L4_DST_PORT"]
translated_dst = translated_dst_ip + ":" + translated_dst_port
else:
translated_dst = translated_dst_ip
elif nat_type == "SAI_NAT_TYPE_SOURCE_NAT":
translated_src_ip = ent[b"SAI_NAT_ENTRY_ATTR_SRC_IP"]
translated_src_ip = ent["SAI_NAT_ENTRY_ATTR_SRC_IP"]
if "SAI_NAT_ENTRY_ATTR_L4_SRC_PORT" in ent:
translated_src_port = ent[b"SAI_NAT_ENTRY_ATTR_L4_SRC_PORT"]
translated_src_port = ent["SAI_NAT_ENTRY_ATTR_L4_SRC_PORT"]
translated_src = translated_src_ip + ":" + translated_src_port
else:
translated_src = translated_src_ip
elif nat_type == "SAI_NAT_TYPE_DOUBLE_NAT":
translated_dst_ip = ent[b"SAI_NAT_ENTRY_ATTR_DST_IP"]
translated_dst_ip = ent["SAI_NAT_ENTRY_ATTR_DST_IP"]
if "SAI_NAT_ENTRY_ATTR_L4_DST_PORT" in ent:
translated_dst_port = ent[b"SAI_NAT_ENTRY_ATTR_L4_DST_PORT"]
translated_dst_port = ent["SAI_NAT_ENTRY_ATTR_L4_DST_PORT"]
translated_dst = translated_dst_ip + ":" + translated_dst_port
else:
translated_dst = translated_dst_ip

translated_src_ip = ent[b"SAI_NAT_ENTRY_ATTR_SRC_IP"]
translated_src_ip = ent["SAI_NAT_ENTRY_ATTR_SRC_IP"]
if "SAI_NAT_ENTRY_ATTR_L4_SRC_PORT" in ent:
translated_src_port = ent[b"SAI_NAT_ENTRY_ATTR_L4_SRC_PORT"]
translated_src_port = ent["SAI_NAT_ENTRY_ATTR_L4_SRC_PORT"]
translated_src = translated_src_ip + ":" + translated_src_port
else:
translated_src = translated_src_ip
Expand Down
2 changes: 1 addition & 1 deletion scripts/nbrshow
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class NbrBase(object):
continue

ent = self.db.get_all('ASIC_DB', s, blocking=True)
br_port_id = ent[b"SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID"][oid_pfx:]
br_port_id = ent["SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID"][oid_pfx:]
if br_port_id not in self.if_br_oid_map:
continue
port_id = self.if_br_oid_map[br_port_id]
Expand Down

0 comments on commit 3e2bfa8

Please sign in to comment.