[Mellanox] Fix issue: set lpmode by platform API does not work (#11732)
- Why I did it Fix issue: set lpmode by platform API does not work - How I did it Fix miss return value in code - How to verify it Manual test
This commit is contained in:
parent
ca546ddec3
commit
46ebd06403
@ -53,6 +53,8 @@ try:
|
||||
SX_PORT_MODULE_STATUS_UNPLUGGED = 2
|
||||
SX_PORT_MODULE_STATUS_PLUGGED_WITH_ERROR = 3
|
||||
SX_PORT_MODULE_STATUS_PLUGGED_DISABLED = 4
|
||||
SX_PORT_ADMIN_STATUS_UP = True
|
||||
SX_PORT_ADMIN_STATUS_DOWN = False
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
@ -571,7 +573,7 @@ class SFP(NvidiaSFPCommon):
|
||||
@classmethod
|
||||
def is_port_admin_status_up(cls, sdk_handle, log_port):
|
||||
_, admin_state = cls._fetch_port_status(sdk_handle, log_port);
|
||||
admin_state == SX_PORT_ADMIN_STATUS_UP
|
||||
return admin_state == SX_PORT_ADMIN_STATUS_UP
|
||||
|
||||
|
||||
@classmethod
|
||||
|
@ -111,3 +111,11 @@ class TestSfp:
|
||||
sfp = SFP(0)
|
||||
assert output_sfp.y_cable_part_number == sfp.read_eeprom(offset, 16).decode()
|
||||
MlxregManager.read_mlxred_eeprom.assert_called_with(132, 4, 16)
|
||||
|
||||
@mock.patch('sonic_platform.sfp.SFP._fetch_port_status')
|
||||
def test_is_port_admin_status_up(self, mock_port_status):
|
||||
mock_port_status.return_value = (0, True)
|
||||
assert SFP.is_port_admin_status_up(None, None)
|
||||
|
||||
mock_port_status.return_value = (0, False)
|
||||
assert not SFP.is_port_admin_status_up(None, None)
|
||||
|
Loading…
Reference in New Issue
Block a user