Skip to content

Commit 7b95211

Browse files
authored
Skip loading media config from media_settings.json for fast-reboot (sonic-net#221)
1 parent 1fd3d16 commit 7b95211

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

sonic-xcvrd/xcvrd/xcvrd.py

+19-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
import sys
1717
import threading
1818
import time
19-
19+
import subprocess
20+
2021
from sonic_py_common import daemon_base, device_info, logger
2122
from sonic_py_common import multi_asic
2223
from swsscommon import swsscommon
@@ -826,6 +827,18 @@ def init_port_sfp_status_tbl(port_mapping, stop_event=threading.Event()):
826827
else:
827828
update_port_transceiver_status_table(logical_port_name, xcvr_table_helper.get_status_tbl(asic_index), sfp_status_helper.SFP_STATUS_INSERTED)
828829

830+
def is_fast_reboot_enabled():
831+
fastboot_enabled = False
832+
state_db_host = daemon_base.db_connect("STATE_DB")
833+
fastboot_tbl = swsscommon.Table(state_db_host, 'FAST_REBOOT')
834+
keys = fastboot_tbl.getKeys()
835+
836+
if "system" in keys:
837+
output = subprocess.check_output('sonic-db-cli STATE_DB get "FAST_REBOOT|system"', shell=True, universal_newlines=True)
838+
if "1" in output:
839+
fastboot_enabled = True
840+
841+
return fastboot_enabled
829842
#
830843
# Helper classes ===============================================================
831844
#
@@ -1463,7 +1476,11 @@ def init(self):
14631476
# Initialize xcvr table helper
14641477
xcvr_table_helper = XcvrTableHelper()
14651478

1466-
self.load_media_settings()
1479+
if is_fast_reboot_enabled():
1480+
self.log_info("Skip loading media_settings.json in case of fast-reboot")
1481+
else:
1482+
self.load_media_settings()
1483+
14671484
warmstart = swsscommon.WarmStart()
14681485
warmstart.initialize("xcvrd", "pmon")
14691486
warmstart.checkWarmStart("xcvrd", "pmon", False)

0 commit comments

Comments
 (0)