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

Cherry-picking PRs from master to resolve database not initialize issue #3279

Closed
wants to merge 4 commits into from
Closed
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 scripts/port2alias
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ from io import StringIO
from portconfig import get_port_config
from sonic_py_common import device_info
from sonic_py_common import multi_asic
from utilities_common.general import load_db_config

# mock the redis for unit test purposes #
try:
Expand Down Expand Up @@ -50,6 +51,7 @@ def translate_line(line, ports):
def main():
(platform, hwsku) = device_info.get_platform_and_hwsku()
ports = {}
load_db_config()
for ns in multi_asic.get_namespace_list():
(ports_ns, _, _) = get_port_config(hwsku=hwsku, platform=platform, asic_name=ns)
ports.update(ports_ns)
Expand Down
2 changes: 2 additions & 0 deletions sfputil/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,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 @@ -548,6 +549,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 @@ -839,3 +839,15 @@ def test_update_firmware_info_to_state_db(self, mock_chassis):
mock_sfp.get_transceiver_info_firmware_versions.return_value = ['a.b.c', 'd.e.f']

sfputil.update_firmware_info_to_state_db("Ethernet0")

@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