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

Fix sfputil CLI failure for multi-asic platforms #3168

Merged
merged 4 commits into from
Feb 23, 2024
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
2 changes: 2 additions & 0 deletions sfputil/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from utilities_common.sfp_helper import covert_application_advertisement_to_output_string
from utilities_common.sfp_helper import QSFP_DATA_MAP
from tabulate import tabulate
from utilities_common.general import load_db_config

VERSION = '3.0'

Expand Down Expand Up @@ -563,6 +564,7 @@ def load_sfputilhelper():


def load_port_config():
load_db_config()
try:
if multi_asic.is_multi_asic():
# For multi ASIC platforms we pass DIR of port_config_file_path and the number of asics
Expand Down
12 changes: 12 additions & 0 deletions tests/sfputil_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1412,3 +1412,15 @@ def test_target_firmware(self, mock_chassis):
result = runner.invoke(sfputil.cli.commands['firmware'].commands['target'], ["Ethernet0", "1"])
assert result.output == 'Target Mode set failed!\n'
assert result.exit_code == EXIT_FAIL

@patch('sfputil.main.multi_asic.is_multi_asic')
@patch('sfputil.main.platform_sfputil', MagicMock())
@patch('sfputil.main.device_info.get_paths_to_platform_and_hwsku_dirs',
MagicMock(return_value=(None, None)))
@patch('sfputil.main.device_info.get_path_to_port_config_file', MagicMock(return_value=('')))
def test_load_port_config(self, mock_is_multi_asic):
mock_is_multi_asic.return_value = True
assert sfputil.load_port_config() == True

mock_is_multi_asic.return_value = False
assert sfputil.load_port_config() == True
Loading