Skip to content

Commit

Permalink
Merge branch 'sonic-net:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
rameshraghupathy authored Nov 17, 2024
2 parents 2469f7f + e772183 commit 30fe529
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
15 changes: 8 additions & 7 deletions sonic-chassisd/scripts/chassisd
Original file line number Diff line number Diff line change
Expand Up @@ -414,13 +414,14 @@ class ModuleUpdater(logger.Logger):
self.hostname_table.set(hostname_key, hostname_fvs)

# Asics that are on the "not online" modules need to be cleaned up
asics = list(self.asic_table.getKeys())
for asic in asics:
fvs = self.asic_table.get(asic)
if isinstance(fvs, list):
fvs = dict(fvs[-1])
if fvs[CHASSIS_MODULE_INFO_NAME_FIELD] in notOnlineModules:
self.asic_table._del(asic)
if notOnlineModules:
asics = list(self.asic_table.getKeys())
for asic in asics:
fvs = self.asic_table.get(asic)
if isinstance(fvs, list):
fvs = dict(fvs[-1])
if CHASSIS_MODULE_INFO_NAME_FIELD in fvs.keys() and fvs[CHASSIS_MODULE_INFO_NAME_FIELD] in notOnlineModules:
self.asic_table._del(asic)

def _get_module_info(self, module_index):
"""
Expand Down
7 changes: 7 additions & 0 deletions sonic-xcvrd/tests/test_xcvrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -3347,6 +3347,13 @@ def test_DaemonXcvrd_init_deinit_cold(self):

status_tbl.hdel.assert_called()

def test_DaemonXcvrd_signal_handler(self):
xcvrd.platform_chassis = MagicMock()
xcvrdaemon = DaemonXcvrd(SYSLOG_IDENTIFIER)
xcvrdaemon.update_log_level = MagicMock()
xcvrdaemon.signal_handler(signal.SIGHUP, None)
xcvrdaemon.update_log_level.assert_called()

@patch('sonic_py_common.device_info.get_paths_to_platform_and_hwsku_dirs', MagicMock(return_value=(test_path, '/invalid/path')))
def test_load_optical_si_file_from_platform_folder(self):
assert optics_si_parser.load_optics_si_settings() != {}
Expand Down
9 changes: 5 additions & 4 deletions sonic-xcvrd/xcvrd/xcvrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import ctypes

from natsort import natsorted
from sonic_py_common import daemon_base, device_info, logger
from sonic_py_common import daemon_base, syslogger
from sonic_py_common import multi_asic
from swsscommon import swsscommon

Expand Down Expand Up @@ -116,7 +116,7 @@
# Global logger instance for helper functions and classes
# TODO: Refactor so that we only need the logger inherited
# by DaemonXcvrd
helper_logger = logger.Logger(SYSLOG_IDENTIFIER)
helper_logger = syslogger.SysLogger(SYSLOG_IDENTIFIER, enable_runtime_config=True)

#
# Helper functions =============================================================
Expand Down Expand Up @@ -2053,7 +2053,7 @@ def retry_eeprom_reading(self):

class DaemonXcvrd(daemon_base.DaemonBase):
def __init__(self, log_identifier, skip_cmis_mgr=False, enable_sff_mgr=False):
super(DaemonXcvrd, self).__init__(log_identifier)
super(DaemonXcvrd, self).__init__(log_identifier, enable_runtime_log_config=True)
self.stop_event = threading.Event()
self.sfp_error_event = threading.Event()
self.skip_cmis_mgr = skip_cmis_mgr
Expand All @@ -2064,7 +2064,8 @@ def __init__(self, log_identifier, skip_cmis_mgr=False, enable_sff_mgr=False):
# Signal handler
def signal_handler(self, sig, frame):
if sig == signal.SIGHUP:
self.log_info("Caught SIGHUP - ignoring...")
self.log_notice("Caught SIGHUP...")
self.update_log_level()
elif sig == signal.SIGINT:
self.log_info("Caught SIGINT - exiting...")
self.stop_event.set()
Expand Down
4 changes: 2 additions & 2 deletions sonic-xcvrd/xcvrd/xcvrd_utilities/media_settings_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import re
from natsort import natsorted

from sonic_py_common import device_info, logger
from sonic_py_common import device_info, syslogger
from swsscommon import swsscommon
from xcvrd import xcvrd
from .xcvr_table_helper import *
Expand All @@ -23,7 +23,7 @@
# This is useful if default value is desired when no match is found for lane speed key
LANE_SPEED_DEFAULT_KEY = LANE_SPEED_KEY_PREFIX + DEFAULT_KEY
SYSLOG_IDENTIFIER = "xcvrd"
helper_logger = logger.Logger(SYSLOG_IDENTIFIER)
helper_logger = syslogger.SysLogger(SYSLOG_IDENTIFIER, enable_runtime_config=True)

PHYSICAL_PORT_NOT_EXIST = -1

Expand Down
4 changes: 2 additions & 2 deletions sonic-xcvrd/xcvrd/xcvrd_utilities/optics_si_parser.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import json
import os

from sonic_py_common import device_info, logger
from sonic_py_common import device_info, syslogger
from xcvrd import xcvrd

g_optics_si_dict = {}

SYSLOG_IDENTIFIER = "xcvrd"
helper_logger = logger.Logger(SYSLOG_IDENTIFIER)
helper_logger = syslogger.SysLogger(SYSLOG_IDENTIFIER, enable_runtime_config=True)

def get_optics_si_settings_value(physical_port, lane_speed, key, vendor_name_str):
GLOBAL_MEDIA_SETTINGS_KEY = 'GLOBAL_MEDIA_SETTINGS'
Expand Down

0 comments on commit 30fe529

Please sign in to comment.