Skip to content

Commit

Permalink
[Mellanox] Fix issue: set lpmode by platform API does not work (#11732)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
Junchao-Mellanox authored and yxieca committed Aug 19, 2022
1 parent dd42d82 commit 75844e6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
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

Expand Down Expand Up @@ -571,7 +573,7 @@ def _fetch_port_status(cls, sdk_handle, log_port):
@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
Expand Down
8 changes: 8 additions & 0 deletions platform/mellanox/mlnx-platform-api/tests/test_sfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,11 @@ def test_sfp_read_eeprom(self):
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)

0 comments on commit 75844e6

Please sign in to comment.