Skip to content

Commit 70d0698

Browse files
mihirpat1tigerfu000
authored andcommitted
CLI enhancements to revtrieve data from TRANSCEIVER_FIRMWARE_INFO table (#3177)
* Retrieve firmware version fields from TRANSCEIVER_FIRMWARE_INFO table Signed-off-by: Mihir Patel <patelmi@microsoft.com> * Fixed test failures * Removed update_firmware_info_to_state_db function * Revert "Removed update_firmware_info_to_state_db function" This reverts commit 68f52a2c3352bc709ab2e3ffe793761f7176a4f0. --------- Signed-off-by: Mihir Patel <patelmi@microsoft.com>
1 parent c711b06 commit 70d0698

File tree

5 files changed

+24
-18
lines changed

5 files changed

+24
-18
lines changed

scripts/sfpshow

+5-2
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ class SFPShow(object):
305305
return output
306306

307307
# Convert sfp info in DB to cli output string
308-
def convert_sfp_info_to_output_string(self, sfp_info_dict):
308+
def convert_sfp_info_to_output_string(self, sfp_info_dict, sfp_firmware_info_dict):
309309
indent = ' ' * 8
310310
output = ''
311311
is_sfp_cmis = 'cmis_rev' in sfp_info_dict
@@ -333,6 +333,8 @@ class SFPShow(object):
333333
output += '{}N/A\n'.format((indent * 2))
334334
elif key == 'application_advertisement':
335335
output += covert_application_advertisement_to_output_string(indent, sfp_info_dict)
336+
elif key == 'active_firmware' or key == 'inactive_firmware':
337+
output += '{}{}: {}\n'.format(indent, data_map[key], sfp_firmware_info_dict[key] if key in sfp_firmware_info_dict else 'N/A')
336338
else:
337339
output += '{}{}: {}\n'.format(indent, data_map[key], sfp_info_dict[key])
338340

@@ -441,12 +443,13 @@ class SFPShow(object):
441443
output = ''
442444

443445
sfp_info_dict = state_db.get_all(state_db.STATE_DB, 'TRANSCEIVER_INFO|{}'.format(interface_name))
446+
sfp_firmware_info_dict = state_db.get_all(state_db.STATE_DB, 'TRANSCEIVER_FIRMWARE_INFO|{}'.format(interface_name))
444447
if sfp_info_dict:
445448
if sfp_info_dict['type'] == RJ45_PORT_TYPE:
446449
output = 'SFP EEPROM is not applicable for RJ45 port\n'
447450
else:
448451
output = 'SFP EEPROM detected\n'
449-
sfp_info_output = self.convert_sfp_info_to_output_string(sfp_info_dict)
452+
sfp_info_output = self.convert_sfp_info_to_output_string(sfp_info_dict, sfp_firmware_info_dict)
450453
output += sfp_info_output
451454

452455
if dump_dom:

sfputil/main.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@
8484
'encoding': 'Encoding',
8585
'connector': 'Connector',
8686
'application_advertisement': 'Application Advertisement',
87-
'active_firmware': 'Active Firmware Version',
88-
'inactive_firmware': 'Inactive Firmware Version',
8987
'hardware_rev': 'Hardware Revision',
9088
'media_interface_code': 'Media Interface Code',
9189
'host_electrical_interface': 'Host Electrical Interface',
@@ -1314,9 +1312,12 @@ def update_firmware_info_to_state_db(port_name):
13141312
state_db = SonicV2Connector(use_unix_socket_path=False, namespace=namespace)
13151313
if state_db is not None:
13161314
state_db.connect(state_db.STATE_DB)
1317-
active_firmware, inactive_firmware = platform_chassis.get_sfp(physical_port).get_transceiver_info_firmware_versions()
1318-
state_db.set(state_db.STATE_DB, 'TRANSCEIVER_INFO|{}'.format(port_name), "active_firmware", active_firmware)
1319-
state_db.set(state_db.STATE_DB, 'TRANSCEIVER_INFO|{}'.format(port_name), "inactive_firmware", inactive_firmware)
1315+
transceiver_firmware_info_dict = platform_chassis.get_sfp(physical_port).get_transceiver_info_firmware_versions()
1316+
if transceiver_firmware_info_dict is not None:
1317+
active_firmware = transceiver_firmware_info_dict.get('active_firmware', 'N/A')
1318+
inactive_firmware = transceiver_firmware_info_dict.get('inactive_firmware', 'N/A')
1319+
state_db.set(state_db.STATE_DB, 'TRANSCEIVER_FIRMWARE_INFO|{}'.format(port_name), "active_firmware", active_firmware)
1320+
state_db.set(state_db.STATE_DB, 'TRANSCEIVER_FIRMWARE_INFO|{}'.format(port_name), "inactive_firmware", inactive_firmware)
13201321

13211322
# 'firmware' subgroup
13221323
@cli.group()

tests/mock_tables/asic1/state_db.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
"media_interface_technology" : "1550 nm DFB",
3030
"vendor_rev" : "XX",
3131
"cmis_rev" : "4.1",
32-
"active_firmware" : "X.X",
33-
"inactive_firmware" : "X.X",
3432
"supported_max_tx_power" : "4.0",
3533
"supported_min_tx_power" : "-22.9",
3634
"supported_max_laser_freq" : "196100",
@@ -70,6 +68,10 @@
7068
"vcclowalarm": "2.9700",
7169
"vcclowwarning": "3.1349"
7270
},
71+
"TRANSCEIVER_FIRMWARE_INFO|Ethernet64": {
72+
"active_firmware": "X.X",
73+
"inactive_firmware": "X.X"
74+
},
7375
"CHASSIS_INFO|chassis 1": {
7476
"psu_num": "2"
7577
},

tests/mock_tables/state_db.json

+8-4
Original file line numberDiff line numberDiff line change
@@ -684,16 +684,17 @@
684684
"media_interface_technology" : "1550 nm DFB",
685685
"vendor_rev" : "XX",
686686
"cmis_rev" : "4.1",
687-
"active_firmware" : "X.X",
688-
"inactive_firmware" : "X.X",
689687
"supported_max_tx_power" : "4.0",
690688
"supported_min_tx_power" : "-22.9",
691689
"supported_max_laser_freq" : "196100",
692690
"supported_min_laser_freq" : "191300"
693691
},
692+
"TRANSCEIVER_FIRMWARE_INFO|Ethernet64": {
693+
"active_firmware": "X.X",
694+
"inactive_firmware": "X.X"
695+
},
694696
"TRANSCEIVER_INFO|Ethernet72": {
695697
"active_apsel_hostlane4": "N/A",
696-
"active_firmware": "0.0",
697698
"is_replaceable": "True",
698699
"application_advertisement": "{1: {'host_electrical_interface_id': 'IB NDR', 'module_media_interface_id': 'Copper cable', 'media_lane_count': 4, 'host_lane_count': 4, 'host_lane_assignment_options': 17}, 2: {'host_electrical_interface_id': 'IB SDR (Arch.Spec.Vol.2)', 'module_media_interface_id': 'Copper cable', 'media_lane_count': 4, 'host_lane_count': 4, 'host_lane_assignment_options': 17}}",
699700
"host_electrical_interface": "N/A",
@@ -710,7 +711,6 @@
710711
"supported_min_laser_freq": "N/A",
711712
"serial": "serial1 ",
712713
"active_apsel_hostlane7": "N/A",
713-
"inactive_firmware": "N/A",
714714
"active_apsel_hostlane1": "N/A",
715715
"type": "OSFP 8X Pluggable Transceiver",
716716
"cable_length": "1.0",
@@ -796,6 +796,10 @@
796796
"txbiaslowalarm": "N/A",
797797
"txbiaslowwarning": "N/A"
798798
},
799+
"TRANSCEIVER_FIRMWARE_INFO|Ethernet72": {
800+
"active_firmware": "0.0",
801+
"inactive_firmware": "N/A"
802+
},
799803
"TRANSCEIVER_STATUS|Ethernet0": {
800804
"status": "67",
801805
"error": "Blocking Error|High temperature"

tests/sfputil_test.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,6 @@ def test_format_dict_value_to_string(self):
151151
'specification_compliance': "sm_media_interface",
152152
'dom_capability': "{'Tx_power_support': 'no', 'Rx_power_support': 'no', 'Voltage_support': 'no', 'Temp_support': 'no'}",
153153
'nominal_bit_rate': '0',
154-
'active_firmware': '0.1',
155-
'inactive_firmware': '0.0',
156154
'hardware_rev': '0.0',
157155
'media_interface_code': '400ZR, DWDM, amplified',
158156
'host_electrical_interface': '400GAUI-8 C2M (Annex 120E)',
@@ -184,7 +182,6 @@ def test_format_dict_value_to_string(self):
184182
" Active App Selection Host Lane 6: 1\n"
185183
" Active App Selection Host Lane 7: 1\n"
186184
" Active App Selection Host Lane 8: 1\n"
187-
" Active Firmware Version: 0.1\n"
188185
" Application Advertisement: 400G CR8 - Host Assign (0x1) - Copper cable - Media Assign (0x2)\n"
189186
" 200GBASE-CR4 (Clause 136) - Host Assign (Unknown) - Unknown - Media Assign (Unknown)\n"
190187
" CMIS Revision: 5.0\n"
@@ -197,7 +194,6 @@ def test_format_dict_value_to_string(self):
197194
" Host Lane Assignment Options: 1\n"
198195
" Host Lane Count: 8\n"
199196
" Identifier: QSFP-DD Double Density 8X Pluggable Transceiver\n"
200-
" Inactive Firmware Version: 0.0\n"
201197
" Length Cable Assembly(m): 0\n"
202198
" Media Interface Code: 400ZR, DWDM, amplified\n"
203199
" Media Interface Technology: C-band tunable laser\n"
@@ -1113,7 +1109,7 @@ def test_firmware_commit_cli(self):
11131109
def test_update_firmware_info_to_state_db(self, mock_chassis):
11141110
mock_sfp = MagicMock()
11151111
mock_chassis.get_sfp = MagicMock(return_value=mock_sfp)
1116-
mock_sfp.get_transceiver_info_firmware_versions.return_value = ['a.b.c', 'd.e.f']
1112+
mock_sfp.get_transceiver_info_firmware_versions.return_value = {'active_firmware' : 'a.b.c', 'inactive_firmware' : 'd.e.f'}
11171113

11181114
sfputil.update_firmware_info_to_state_db("Ethernet0")
11191115

0 commit comments

Comments
 (0)