Skip to content

Commit

Permalink
Removed update_firmware_info_to_state_db function
Browse files Browse the repository at this point in the history
  • Loading branch information
mihirpat1 committed Feb 26, 2024
1 parent 62d3100 commit 68f52a2
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 32 deletions.
18 changes: 0 additions & 18 deletions sfputil/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
14 changes: 0 additions & 14 deletions tests/sfputil_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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"])
Expand All @@ -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)))
Expand Down

0 comments on commit 68f52a2

Please sign in to comment.