DellEMC: Z9332f - SFP API get_error_description implementation (#9071)

* DellEMC: Z9332f - SFP API get_error_description implementation

* Update error message
This commit is contained in:
Arun Saravanan Balachandran 2021-11-05 05:00:09 +05:30 committed by GitHub
parent 2c801ef442
commit 2d7840ce9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1416,3 +1416,34 @@ class Sfp(SfpBase):
bool: True if it is replaceable.
"""
return True
def get_error_description(self):
"""
Retrives the error descriptions of the SFP module
Returns:
String that represents the current error descriptions of vendor specific errors
In case there are multiple errors, they should be joined by '|',
like: "Bad EEPROM|Unsupported cable"
"""
if not self.get_presence():
return self.SFP_STATUS_UNPLUGGED
else:
if not os.path.isfile(self.eeprom_path):
return "EEPROM driver is not attached"
if self.sfp_type == 'SFP':
offset = SFP_INFO_OFFSET
elif self.sfp_type == 'QSFP':
offset = QSFP_INFO_OFFSET
elif self.sfp_type == 'QSFP_DD':
offset = QSFP_DD_PAGE0
try:
with open(self.eeprom_path, mode="rb", buffering=0) as eeprom:
eeprom.seek(offset)
eeprom.read(1)
except OSError as e:
return "EEPROM read failed ({})".format(e.strerror)
return self.SFP_STATUS_OK