Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CMIS] 'get_transceiver_info' should return 'None' when CMIS cable EEPROM is not ready #305

Merged
merged 2 commits into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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():
keboliu marked this conversation as resolved.
Show resolved Hide resolved
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