Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sfputil] add logic to avoid access none present SFP eeprom #353

Merged
merged 1 commit into from
Oct 22, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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