Skip to content

Commit

Permalink
[Mellanox] get_error_description should return Not supported for modu…
Browse files Browse the repository at this point in the history
…les that does not support this API
  • Loading branch information
Junchao-Mellanox committed Dec 11, 2024
1 parent 7bdf8d4 commit 3774e54
Show file tree
Hide file tree
Showing 2 changed files with 6 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 @@ -678,7 +678,9 @@ def get_error_description(self):
if self.is_sw_control():
api = self.get_xcvr_api()
return api.get_error_description() if api else None
except:
except NotImplementedError:
return 'Not supported'
except Exception:
return self.SFP_STATUS_INITIALIZING

oper_status, error_code = self._get_module_info(self.sdk_index)
Expand Down
3 changes: 3 additions & 0 deletions platform/mellanox/mlnx-platform-api/tests/test_sfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ def test_sfp_get_error_status(self, mock_get_error_code, mock_control):
mock_control.side_effect = RuntimeError('')
description = sfp.get_error_description()
assert description == 'Initializing'

mock_control.side_effect = NotImplementedError('')
assert description == 'Not supported'

@mock.patch('sonic_platform.sfp.SFP._get_page_and_page_offset')
@mock.patch('sonic_platform.sfp.SFP._is_write_protected')
Expand Down

0 comments on commit 3774e54

Please sign in to comment.