[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:
Junchao-Mellanox 2022-08-18 18:07:38 +08:00 committed by GitHub
parent ca546ddec3
commit 46ebd06403
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -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

View File

@ -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)