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

Initialize unsupported values to 'N/A' in CmisApi::get_transceiver_info #545

Merged
merged 9 commits into from
Mar 1, 2025
16 changes: 15 additions & 1 deletion sonic_platform_base/sonic_xcvr/api/public/cmis.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,21 @@ def get_transceiver_info(self):
"cable_length": float(admin_info[consts.LENGTH_ASSEMBLY_FIELD]),
"nominal_bit_rate": 0, # Not supported
"vendor_date": admin_info[consts.VENDOR_DATE_FIELD],
"vendor_oui": admin_info[consts.VENDOR_OUI_FIELD]
"vendor_oui": admin_info[consts.VENDOR_OUI_FIELD],
"is_replaceable": "N/A", # Not supported
"dom_capability": "N/A", # Not supported
"active_apsel_hostlane1": "N/A", # Not supported
"active_apsel_hostlane2": "N/A", # Not supported
"active_apsel_hostlane3": "N/A", # Not supported
"active_apsel_hostlane4": "N/A", # Not supported
"active_apsel_hostlane5": "N/A", # Not supported
"active_apsel_hostlane6": "N/A", # Not supported
"active_apsel_hostlane7": "N/A", # Not supported
"active_apsel_hostlane8": "N/A", # Not supported
"supported_max_tx_power": "N/A", # Not supported
"supported_min_tx_power": "N/A", # Not supported
"supported_max_laser_freq": "N/A", # Not supported
"supported_min_laser_freq": "N/A" # Not supported
}
appl_advt = self.get_application_advertisement()
xcvr_info['application_advertisement'] = str(appl_advt) if len(appl_advt) > 0 else 'N/A'
Expand Down
12 changes: 9 additions & 3 deletions tests/sonic_xcvr/test_cmis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,13 @@ def test_module_fw_upgrade(self, input_param, mock_response, expected):
'media_lane_assignment_option': 1,
'connector': 'LC',
'host_lane_assignment_option': 1,
'vendor_date': '21010100'
'vendor_date': '21010100',
'dom_capability': 'N/A',
'is_replaceable': 'N/A',
'supported_max_laser_freq': 'N/A',
'supported_max_tx_power': 'N/A',
'supported_min_laser_freq': 'N/A',
'supported_min_tx_power': 'N/A'
}
)
])
Expand Down Expand Up @@ -1526,11 +1532,11 @@ def test_get_transceiver_info(self, mock_response, expected):
self.api.get_cmis_rev = MagicMock()
self.api.get_cmis_rev.return_value = mock_response[10]
self.api.get_module_fw_info = MagicMock()
self.api.get_module_fw_info.return_value = mock_response[14]
self.api.get_module_media_type = MagicMock()
self.api.get_module_media_type.return_value = mock_response[13]
self.api.get_module_hardware_revision = MagicMock()
self.api.get_module_hardware_revision.return_value = '0.0'
self.api.get_module_fw_info.return_value = mock_response[14]
self.api.is_flat_memory = MagicMock()
self.api.is_flat_memory.return_value = False
result = self.api.get_transceiver_info()
Expand Down Expand Up @@ -3082,7 +3088,7 @@ def test_get_error_description(self):
}
self.api.xcvr_eeprom.read = MagicMock()
self.api.xcvr_eeprom.read.return_value = 0x10

result = self.api.get_error_description()
assert result is 'OK'

Expand Down
Loading