Skip to content

Commit

Permalink
[CMIS] 'get_transceiver_info' should return 'None' when CMIS cable EE…
Browse files Browse the repository at this point in the history
…PROM is not ready (#305)

* get_transceiver_info should return None when cmis cable eeprom is not ready

Signed-off-by: Kebo Liu <kebol@nvidia.com>

* Add more comments to describe the change

Signed-off-by: Kebo Liu <kebol@nvidia.com>

Signed-off-by: Kebo Liu <kebol@nvidia.com>
  • Loading branch information
keboliu authored Sep 2, 2022
1 parent e1b26fe commit 75c055e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
11 changes: 10 additions & 1 deletion sonic_platform_base/sonic_xcvr/api/public/cmis.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,16 @@ def get_transceiver_info(self):
xcvr_info['active_firmware'] = self.get_module_active_firmware()
xcvr_info['inactive_firmware'] = self.get_module_inactive_firmware()
xcvr_info['specification_compliance'] = self.get_module_media_type()
return xcvr_info

# In normal case will get a valid value for each of the fields. If get a 'None' value
# means there was a failure while reading the EEPROM, either because the EEPROM was
# not ready yet or experincing some other issues. It shouldn't return a dict with a
# wrong field value, instead should return a 'None' to indicate to XCVRD that retry is
# needed.
if None in xcvr_info.values():
return None
else:
return xcvr_info

def get_transceiver_bulk_status(self):
rx_los = self.get_rx_los()
Expand Down
4 changes: 4 additions & 0 deletions tests/sonic_xcvr/test_cmis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,10 @@ def test_get_transceiver_info(self, mock_response, expected):
self.api.is_flat_memory.return_value = False
result = self.api.get_transceiver_info()
assert result == expected
# Test negative path
self.api.get_cmis_rev.return_value = None
result = self.api.get_transceiver_info()
assert result == None


@pytest.mark.parametrize("mock_response, expected",[
Expand Down

0 comments on commit 75c055e

Please sign in to comment.