From 68f52a2c3352bc709ab2e3ffe793761f7176a4f0 Mon Sep 17 00:00:00 2001 From: Mihir Patel Date: Mon, 26 Feb 2024 23:49:12 +0000 Subject: [PATCH] Removed update_firmware_info_to_state_db function --- sfputil/main.py | 18 ------------------ tests/sfputil_test.py | 14 -------------- 2 files changed, 32 deletions(-) diff --git a/sfputil/main.py b/sfputil/main.py index 23be1b4d82..534004cdfd 100644 --- a/sfputil/main.py +++ b/sfputil/main.py @@ -1304,21 +1304,6 @@ def reset(port_name): i += 1 -def update_firmware_info_to_state_db(port_name): - physical_port = logical_port_to_physical_port_index(port_name) - - namespaces = multi_asic.get_front_end_namespaces() - for namespace in namespaces: - state_db = SonicV2Connector(use_unix_socket_path=False, namespace=namespace) - if state_db is not None: - state_db.connect(state_db.STATE_DB) - transceiver_firmware_info_dict = platform_chassis.get_sfp(physical_port).get_transceiver_info_firmware_versions() - if transceiver_firmware_info_dict is not None: - active_firmware = transceiver_firmware_info_dict.get('active_firmware', 'N/A') - inactive_firmware = transceiver_firmware_info_dict.get('inactive_firmware', 'N/A') - state_db.set(state_db.STATE_DB, 'TRANSCEIVER_FIRMWARE_INFO|{}'.format(port_name), "active_firmware", active_firmware) - state_db.set(state_db.STATE_DB, 'TRANSCEIVER_FIRMWARE_INFO|{}'.format(port_name), "inactive_firmware", inactive_firmware) - # 'firmware' subgroup @cli.group() def firmware(): @@ -1509,7 +1494,6 @@ def download_firmware(port_name, filepath): click.echo("Platform doesn't implement optoe write max change. Skipping value restore!") status = api.cdb_firmware_download_complete() - update_firmware_info_to_state_db(port_name) click.echo('CDB: firmware download complete') return status @@ -1537,7 +1521,6 @@ def run(port_name, mode): click.echo('Failed to run firmware in mode={}! CDB status: {}'.format(mode, status)) sys.exit(EXIT_FAIL) - update_firmware_info_to_state_db(port_name) click.echo("Firmware run in mode={} success".format(mode)) # 'commit' subcommand @@ -1559,7 +1542,6 @@ def commit(port_name): click.echo('Failed to commit firmware! CDB status: {}'.format(status)) sys.exit(EXIT_FAIL) - update_firmware_info_to_state_db(port_name) click.echo("Firmware commit successful") # 'upgrade' subcommand diff --git a/tests/sfputil_test.py b/tests/sfputil_test.py index cfb7ed75c7..dbe6dac30b 100644 --- a/tests/sfputil_test.py +++ b/tests/sfputil_test.py @@ -970,7 +970,6 @@ def test_show_fwversion_Rj45(self, mock_chassis): @patch('builtins.open') @patch('sfputil.main.platform_chassis') @patch('sfputil.main.logical_port_to_physical_port_index', MagicMock(return_value=1)) - @patch('sfputil.main.update_firmware_info_to_state_db', MagicMock()) def test_download_firmware(self, mock_chassis, mock_file): mock_file.return_value.tell.return_value = 0 mock_sfp = MagicMock() @@ -1087,7 +1086,6 @@ def test_firmware_download_RJ45(self): @patch('sfputil.main.is_sfp_present', MagicMock(return_value=True)) @patch('sfputil.main.is_port_type_rj45', MagicMock(return_value=False)) @patch('sfputil.main.run_firmware', MagicMock(return_value=1)) - @patch('sfputil.main.update_firmware_info_to_state_db', MagicMock()) def test_firmware_run_cli(self): runner = CliRunner() result = runner.invoke(sfputil.cli.commands['firmware'].commands['run'], ["Ethernet0"]) @@ -1096,23 +1094,11 @@ def test_firmware_run_cli(self): @patch('sfputil.main.is_sfp_present', MagicMock(return_value=True)) @patch('sfputil.main.is_port_type_rj45', MagicMock(return_value=False)) @patch('sfputil.main.commit_firmware', MagicMock(return_value=1)) - @patch('sfputil.main.update_firmware_info_to_state_db', MagicMock()) def test_firmware_commit_cli(self): runner = CliRunner() result = runner.invoke(sfputil.cli.commands['firmware'].commands['commit'], ["Ethernet0"]) assert result.exit_code == 0 - @patch('sfputil.main.logical_port_to_physical_port_index', MagicMock(return_value=1)) - @patch('sonic_py_common.multi_asic.get_front_end_namespaces', MagicMock(return_value=[''])) - @patch('sfputil.main.SonicV2Connector', MagicMock()) - @patch('sfputil.main.platform_chassis') - def test_update_firmware_info_to_state_db(self, mock_chassis): - mock_sfp = MagicMock() - mock_chassis.get_sfp = MagicMock(return_value=mock_sfp) - mock_sfp.get_transceiver_info_firmware_versions.return_value = {'active_firmware' : 'a.b.c', 'inactive_firmware' : 'd.e.f'} - - sfputil.update_firmware_info_to_state_db("Ethernet0") - @patch('sfputil.main.is_port_type_rj45', MagicMock(return_value=False)) @patch('sfputil.main.logical_port_to_physical_port_index', MagicMock(return_value=1)) @patch('sfputil.main.platform_sfputil', MagicMock(is_logical_port=MagicMock(return_value=1)))