@@ -90,6 +90,7 @@ INVALID_SLOT = ModuleBase.MODULE_INVALID_SLOT
90
90
INVALID_MODULE_INDEX = - 1
91
91
INVALID_IP = '0.0.0.0'
92
92
93
+ CHASSIS_MODULE_ADMIN_STATUS = 'admin_status'
93
94
MODULE_ADMIN_DOWN = 0
94
95
MODULE_ADMIN_UP = 1
95
96
@@ -257,8 +258,18 @@ class ModuleUpdater(logger.Logger):
257
258
if isinstance (fvs , list ) and fvs [0 ] is True :
258
259
fvs = dict (fvs [- 1 ])
259
260
return fvs [CHASSIS_MODULE_INFO_OPERSTATUS_FIELD ]
260
- return ModuleBase .MODULE_STATUS_EMPTY
261
-
261
+ return ModuleBase .MODULE_STATUS_EMPTY
262
+
263
+ def get_module_admin_status (self , chassis_module_name ):
264
+ config_db = daemon_base .db_connect ("CONFIG_DB" )
265
+ vtable = swsscommon .Table (config_db , CHASSIS_CFG_TABLE )
266
+ fvs = vtable .get (chassis_module_name )
267
+ if isinstance (fvs , list ) and fvs [0 ] is True :
268
+ fvs = dict (fvs [- 1 ])
269
+ return fvs [CHASSIS_MODULE_ADMIN_STATUS ]
270
+ else :
271
+ return 'up'
272
+
262
273
def module_db_update (self ):
263
274
notOnlineModules = []
264
275
@@ -317,16 +328,20 @@ class ModuleUpdater(logger.Logger):
317
328
elif prev_status != ModuleBase .MODULE_STATUS_ONLINE :
318
329
self .log_notice ("Module {} is on-line!" .format (key ))
319
330
320
- for asic_id , asic in enumerate (module_info_dict [CHASSIS_MODULE_INFO_ASICS ]):
321
- asic_global_id , asic_pci_addr = asic
322
- asic_key = "%s%s" % (CHASSIS_ASIC , asic_global_id )
323
- if not self ._is_supervisor ():
324
- asic_key = "%s|%s" % (key , asic_key )
331
+ module_cfg_status = self .get_module_admin_status (key )
332
+
333
+ #Only populate the related tables when the module configure is up
334
+ if module_cfg_status != 'down' :
335
+ for asic_id , asic in enumerate (module_info_dict [CHASSIS_MODULE_INFO_ASICS ]):
336
+ asic_global_id , asic_pci_addr = asic
337
+ asic_key = "%s%s" % (CHASSIS_ASIC , asic_global_id )
338
+ if not self ._is_supervisor ():
339
+ asic_key = "%s|%s" % (key , asic_key )
325
340
326
- asic_fvs = swsscommon .FieldValuePairs ([(CHASSIS_ASIC_PCI_ADDRESS_FIELD , asic_pci_addr ),
327
- (CHASSIS_MODULE_INFO_NAME_FIELD , key ),
328
- (CHASSIS_ASIC_ID_IN_MODULE_FIELD , str (asic_id ))])
329
- self .asic_table .set (asic_key , asic_fvs )
341
+ asic_fvs = swsscommon .FieldValuePairs ([(CHASSIS_ASIC_PCI_ADDRESS_FIELD , asic_pci_addr ),
342
+ (CHASSIS_MODULE_INFO_NAME_FIELD , key ),
343
+ (CHASSIS_ASIC_ID_IN_MODULE_FIELD , str (asic_id ))])
344
+ self .asic_table .set (asic_key , asic_fvs )
330
345
331
346
# In line card push the hostname of the module and num_asics to the chassis state db.
332
347
# The hostname is used as key to access chassis app db entries
@@ -518,9 +533,9 @@ class ModuleUpdater(logger.Logger):
518
533
asic = CHASSIS_ASIC + str (asic_id )
519
534
520
535
# Cleanup the chassis app db entries using lua script
521
- redis_cmd = 'redis-cli -h redis_chassis.server -p 6380 -n 12 EVALSHA ' + self .chassis_app_db_clean_sha + ' 0 ' + lc + ' ' + asic
536
+ redis_cmd = [ 'redis-cli' , '-h' , ' redis_chassis.server' , '-p' , ' 6380' , '-n' , '12' , ' EVALSHA' , self .chassis_app_db_clean_sha , '0' , lc , asic ]
522
537
try :
523
- subp = subprocess .Popen (redis_cmd , shell = True , stdout = subprocess .PIPE , stderr = subprocess .PIPE , universal_newlines = True )
538
+ subp = subprocess .Popen (redis_cmd , shell = False , stdout = subprocess .PIPE , stderr = subprocess .PIPE , universal_newlines = True )
524
539
subp .communicate ()
525
540
self .log_notice ("Cleaned up chassis app db entries for {}({})/{}" .format (module , lc , asic ))
526
541
except Exception :
0 commit comments