Skip to content

Commit

Permalink
[lldp] fix issue sonic-net#79 - AttributeError: 'NoneType' object has…
Browse files Browse the repository at this point in the history
… no attribute 'decode' (sonic-net#80)

* [lldp] fix issue sonic-net#79
*  review comments - set local mgmt ip to '' if missing
  • Loading branch information
mykolaf authored and qiluo-msft committed Aug 13, 2018
1 parent 1577f4c commit fd9ac3e
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/sonic_ax_impl/mibs/ieee802_1ab.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def update_data(self):
break

if b"set" in data:
self.update_interface_data(interface.encode('utf-8'))
self.update_interface_data(interface.encode())

def local_port_num(self, sub_id):
if len(sub_id) == 0:
Expand Down Expand Up @@ -266,10 +266,13 @@ def reinit_data(self):
"""
# establish connection to application database.
self.db_conn.connect(mibs.APPL_DB)
self.mgmt_ip_str = self.db_conn.get(mibs.APPL_DB, mibs.LOC_CHASSIS_TABLE,
b'lldp_loc_man_addr').decode('utf-8')
logger.debug("Got mgmt ip from db : {}".format(self.mgmt_ip_str))
mgmt_ip_bytes = self.db_conn.get(mibs.APPL_DB, mibs.LOC_CHASSIS_TABLE, b'lldp_loc_man_addr')

if not mgmt_ip_bytes:
self.mgmt_ip_str = ''
else:
self.mgmt_ip_str = mgmt_ip_bytes.decode()
logger.debug("Got mgmt ip from db : {}".format(self.mgmt_ip_str))
try:
mgmt_ip_sub_oid = tuple([int(i) for i in self.mgmt_ip_str.split('.')])
except ValueError:
Expand Down Expand Up @@ -425,7 +428,7 @@ def update_rem_if_mgmt(self, if_oid, if_name):
b'lldp_rem_man_addr')
if not mgmt_ip_bytes:
return
mgmt_ip_str = mgmt_ip_bytes.decode('utf-8')
mgmt_ip_str = mgmt_ip_bytes.decode()
subtype = self.get_subtype(mgmt_ip_str)
ip_hex = self.get_ip_hex(mgmt_ip_str, subtype)
mgmt_ip_sub_oid = None
Expand Down Expand Up @@ -459,11 +462,11 @@ def update_data(self):
break

if b"set" in data:
self.update_rem_if_mgmt(if_index, interface.encode('utf-8'))
self.update_rem_if_mgmt(if_index, interface.encode())
elif b"del" in data:
# some remote data about that neighbor is gone, del it and try to query again
self.if_range = [sub_oid for sub_oid in self.if_range if sub_oid[0] != if_index]
self.update_rem_if_mgmt(if_index, interface.encode('utf-8'))
self.update_rem_if_mgmt(if_index, interface.encode())

def reinit_data(self):
"""
Expand Down

0 comments on commit fd9ac3e

Please sign in to comment.