[pddf]: fix Observing the following error while running 'sfputil show lpmode' command. (#12636)

Why I did it
Fixes #12634

Observing the following error while running 'sfputil show lpmode' command.
AttributeError: 'Sfp' object has no attribute 'get_power_set'

Root Cause: get_power_set() is defined for QSFP28 and QSFP+ i.e. Sff8636 and Sff8634. However, the function is not defined in the optoe_base class.

How I did it
To use get_power_set(), we need to initialise the 'api' via get_xcvr_api() and then use it to run get_power_set().
This commit is contained in:
FuzailBrcm 2022-12-18 04:12:15 +05:30 committed by GitHub
parent 20cad3b2f5
commit 8788f1cc0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -205,7 +205,9 @@ class PddfSfp(SfpOptoeBase):
lpmode = super().get_lpmode() lpmode = super().get_lpmode()
elif xcvr_id == 0x11 or xcvr_id == 0x0d or xcvr_id == 0x0c: elif xcvr_id == 0x11 or xcvr_id == 0x0d or xcvr_id == 0x0c:
# QSFP28, QSFP+, QSFP # QSFP28, QSFP+, QSFP
power_set = self.get_power_set() # get_power_set() is not defined in the optoe_base class
api = self.get_xcvr_api()
power_set = api.get_power_set()
power_override = self.get_power_override() power_override = self.get_power_override()
# By default the lpmode pin is pulled high as mentioned in the sff community # By default the lpmode pin is pulled high as mentioned in the sff community
return power_set if power_override else True return power_set if power_override else True
@ -343,9 +345,9 @@ class PddfSfp(SfpOptoeBase):
elif xcvr_id == 0x11 or xcvr_id == 0x0d or xcvr_id == 0x0c: elif xcvr_id == 0x11 or xcvr_id == 0x0d or xcvr_id == 0x0c:
# QSFP28, QSFP+, QSFP # QSFP28, QSFP+, QSFP
if lpmode is True: if lpmode is True:
self.set_power_override(True, True) status = self.set_power_override(True, True)
else: else:
self.set_power_override(True, False) status = self.set_power_override(True, False)
return status return status