From 7b952116cc4e44dfc499b0ec7fa2948ba51f9271 Mon Sep 17 00:00:00 2001 From: tjchadaga <85581939+tjchadaga@users.noreply.github.com> Date: Tue, 9 Nov 2021 20:04:52 -0800 Subject: [PATCH] Skip loading media config from media_settings.json for fast-reboot (#221) --- sonic-xcvrd/xcvrd/xcvrd.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/sonic-xcvrd/xcvrd/xcvrd.py b/sonic-xcvrd/xcvrd/xcvrd.py index ddc1d075e49a..f86419a2dff5 100644 --- a/sonic-xcvrd/xcvrd/xcvrd.py +++ b/sonic-xcvrd/xcvrd/xcvrd.py @@ -16,7 +16,8 @@ import sys import threading import time - + import subprocess + from sonic_py_common import daemon_base, device_info, logger from sonic_py_common import multi_asic from swsscommon import swsscommon @@ -826,6 +827,18 @@ def init_port_sfp_status_tbl(port_mapping, stop_event=threading.Event()): else: update_port_transceiver_status_table(logical_port_name, xcvr_table_helper.get_status_tbl(asic_index), sfp_status_helper.SFP_STATUS_INSERTED) +def is_fast_reboot_enabled(): + fastboot_enabled = False + state_db_host = daemon_base.db_connect("STATE_DB") + fastboot_tbl = swsscommon.Table(state_db_host, 'FAST_REBOOT') + keys = fastboot_tbl.getKeys() + + if "system" in keys: + output = subprocess.check_output('sonic-db-cli STATE_DB get "FAST_REBOOT|system"', shell=True, universal_newlines=True) + if "1" in output: + fastboot_enabled = True + + return fastboot_enabled # # Helper classes =============================================================== # @@ -1463,7 +1476,11 @@ def init(self): # Initialize xcvr table helper xcvr_table_helper = XcvrTableHelper() - self.load_media_settings() + if is_fast_reboot_enabled(): + self.log_info("Skip loading media_settings.json in case of fast-reboot") + else: + self.load_media_settings() + warmstart = swsscommon.WarmStart() warmstart.initialize("xcvrd", "pmon") warmstart.checkWarmStart("xcvrd", "pmon", False)