[Mellanox] Redirect ethtool stderr to subprocess for better error log (#12038)
- Why I did it ethtool print error logs when EEPROM of a SFP is not available. It prints error like this: INFO pmon#/supervisord: xcvrd Cannot get module EEPROM information: Input/output error INFO pmon#/supervisord: xcvrd Cannot get Module EEPROM data: Invalid argument However, this log does not contain the relevant SFP index which is hard for developer/qa to find the exactly SFP. - How I did it Redirect ethtool stderr to subprocess and log it better - How to verify it Manual test
This commit is contained in:
parent
ab0edff4cb
commit
5ecb93f7e8
@ -359,7 +359,8 @@ class SFP(NvidiaSFPCommon):
|
||||
try:
|
||||
output = subprocess.check_output(ethtool_cmd,
|
||||
shell=True,
|
||||
universal_newlines=True)
|
||||
universal_newlines=True,
|
||||
stderr=subprocess.PIPE)
|
||||
output_lines = output.splitlines()
|
||||
first_line_raw = output_lines[0]
|
||||
if "Offset" in first_line_raw:
|
||||
@ -367,6 +368,7 @@ class SFP(NvidiaSFPCommon):
|
||||
line_split = line.split()
|
||||
eeprom_raw = eeprom_raw + line_split[1:]
|
||||
except subprocess.CalledProcessError as e:
|
||||
logger.log_notice("Failed to get EEPROM data for sfp {}: {}".format(self.index, e.stderr))
|
||||
return None
|
||||
|
||||
eeprom_raw = list(map(lambda h: int(h, base=16), eeprom_raw))
|
||||
|
Loading…
Reference in New Issue
Block a user