Skip to content
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
14 changes: 13 additions & 1 deletion sonic_platform_base/sonic_xcvr/api/public/cmis.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ def get_model(self):
'''
return self.xcvr_eeprom.read(consts.VENDOR_PART_NO_FIELD)

def get_cable_length_type(self):
'''
This function returns the cable type of the module
'''
return "Length Cable Assembly(m)"

def get_cable_length(self):
'''
This function returns the cable length of the module
'''
return self.xcvr_eeprom.read(consts.LENGTH_ASSEMBLY_FIELD)

def get_vendor_rev(self):
'''
This function returns the revision level for part number provided by vendor
Expand Down Expand Up @@ -146,7 +158,6 @@ def get_transceiver_info(self):
"encoding": "N/A", # Not supported
"ext_identifier": "%s (%sW Max)" % (power_class, max_power),
"ext_rateselect_compliance": "N/A", # Not supported
"cable_type": "Length Cable Assembly(m)",
"cable_length": float(admin_info[consts.LENGTH_ASSEMBLY_FIELD]),
"nominal_bit_rate": 0, # Not supported
"vendor_date": admin_info[consts.VENDOR_DATE_FIELD],
Expand All @@ -160,6 +171,7 @@ def get_transceiver_info(self):
xcvr_info['media_lane_count'] = self.get_media_lane_count()
xcvr_info['host_lane_assignment_option'] = self.get_host_lane_assignment_option()
xcvr_info['media_lane_assignment_option'] = self.get_media_lane_assignment_option()
xcvr_info['cable_type'] = self.get_cable_length_type()
apsel_dict = self.get_active_apsel_hostlane()
for lane in range(1, self.NUM_CHANNELS+1):
xcvr_info["%s%d" % ("active_apsel_hostlane", lane)] = \
Expand Down
13 changes: 13 additions & 0 deletions tests/sonic_xcvr/test_cmis.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ def test_get_model(self, mock_response, expected):
result = self.api.get_model()
assert result == expected

def test_get_cable_length_type(self):
assert self.api.get_cable_length_type() == "Length Cable Assembly(m)"

@pytest.mark.parametrize("mock_response, expected", [
("0.0", "0.0"),
("1.2", "1.2")
])
def test_get_cable_length(self, mock_response, expected):
self.api.xcvr_eeprom.read = MagicMock()
self.api.xcvr_eeprom.read.return_value = mock_response
result = self.api.get_cable_length()
assert result == expected

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