Skip to content

Commit

Permalink
add logic to avoid access none present SFP (sonic-net#353)
Browse files Browse the repository at this point in the history
  • Loading branch information
keboliu authored and jleveque committed Oct 22, 2018
1 parent cfc580c commit e3a2feb
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions sfputil/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,11 @@ def port_eeprom_data_string_pretty(logical_port_name, dump_dom):

for physical_port in physical_port_list:
port_name = get_physical_port_name(logical_port_name, i, ganged)
eeprom_dict = platform_sfputil.get_eeprom_dict(physical_port)
if not platform_sfputil.get_presence(physical_port):
eeprom_dict = None
else:
eeprom_dict = platform_sfputil.get_eeprom_dict(physical_port)

if eeprom_dict is not None:
eeprom_iface_dict = eeprom_dict.get('interface')
iface_data_dict = eeprom_iface_dict.get('data')
Expand Down Expand Up @@ -228,7 +232,10 @@ def port_eeprom_data_string_pretty_oneline(logical_port_name,
ganged = True

for physical_port in physical_port_list:
eeprom_dict = platform_sfputil.get_eeprom_dict(physical_port)
if not platform_sfputil.get_presence(physical_port):
eeprom_dict = None
else:
eeprom_dict = platform_sfputil.get_eeprom_dict(physical_port)

# Only print detected sfp ports for oneline
if eeprom_dict is not None:
Expand Down Expand Up @@ -266,7 +273,11 @@ def port_eeprom_data_raw_string_pretty(logical_port_name):

for physical_port in physical_port_list:
port_name = get_physical_port_name(logical_port_name, i, ganged)
eeprom_raw = platform_sfputil.get_eeprom_raw(physical_port)
if not platform_sfputil.get_presence(physical_port):
eeprom_raw = None
else:
eeprom_raw = platform_sfputil.get_eeprom_raw(physical_port)

if eeprom_raw is None:
result += get_sfp_eeprom_status_string(port_name, False)
result += "\n"
Expand Down

0 comments on commit e3a2feb

Please sign in to comment.