@@ -20,13 +20,15 @@ class MuxStateWriter(object):
2020 Class used to write standby mux state to APP DB
2121 """
2222
23- def __init__ (self , activeactive , activestandby ):
23+ def __init__ (self , activeactive , activestandby , shutdown_module ):
2424 self .config_db_connector = None
2525 self .appl_db_connector = None
2626 self .state_db_connector = None
2727 self .asic_db_connector = None
2828 self .default_active_active_state = activeactive
2929 self .default_active_standby_state = activestandby
30+ self .shutdown_module = shutdown_module
31+ self .is_shutdwon = (self .shutdown_module != None )
3032
3133 @property
3234 def config_db (self ):
@@ -97,7 +99,15 @@ def is_warmrestart(self):
9799 tbl = Table (self .state_db , 'WARM_RESTART_ENABLE_TABLE' )
98100 (status , value ) = tbl .hget ('system' , 'enable' )
99101
100- return status and value == 'true'
102+ if status and value == 'true' :
103+ return True
104+
105+ if self .shutdown_module :
106+ (status , value ) = tbl .hget (self .shutdown_module , 'enable' )
107+ if status and value == 'true' :
108+ return True
109+
110+ return False
101111
102112 def get_all_mux_intfs_modes (self ):
103113 """
@@ -153,7 +163,7 @@ def apply_mux_config(self):
153163 # If not running on a dual ToR system, take no action
154164 return
155165
156- if self .is_warmrestart :
166+ if self .is_warmrestart and self . is_shutdwon :
157167 # If in warmrestart context, take no action
158168 logger .log_warning ("Skip setting mux state due to ongoing warmrestart." )
159169 return
@@ -178,12 +188,12 @@ def apply_mux_config(self):
178188 parser .add_argument ('-s' , '--active_standby' ,
179189 help = 'state: intial state for "auto" and/or "manual" config in active-standby mode, default "standby"' ,
180190 type = str , required = False , default = 'standby' )
181- parser .add_argument ('--shutdown' , help = 'write mux state after shutdown other services, supported: mux' ,
182- type = str , required = False , choices = ['mux' ] )
191+ parser .add_argument ('--shutdown' , help = 'write mux state after shutdown other services, supported: mux, bgp ' ,
192+ type = str , required = False , choices = ['mux' , 'bgp' ], default = None )
183193 args = parser .parse_args ()
184194 active_active_state = args .active_active
185195 active_standby_state = args .active_standby
186- if args .shutdown == 'mux' :
196+ if args .shutdown in [ 'mux' , 'bgp' ] :
187197 active_active_state = "standby"
188- mux_writer = MuxStateWriter (activeactive = active_active_state , activestandby = active_standby_state )
198+ mux_writer = MuxStateWriter (activeactive = active_active_state , activestandby = active_standby_state , shutdown_module = args . shutdown )
189199 mux_writer .apply_mux_config ()
0 commit comments