Skip to content

Commit

Permalink
fix based on review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
JunhongMao committed Apr 26, 2024
1 parent 1ed77d3 commit 2cd0832
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions sonic-chassisd/scripts/chassisd
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ INVALID_SLOT = ModuleBase.MODULE_INVALID_SLOT
INVALID_MODULE_INDEX = -1
INVALID_IP = '0.0.0.0'

CHASSIS_MODULE_ADMIN_STATUS = 'admin_status'
MODULE_ADMIN_DOWN = 0
MODULE_ADMIN_UP = 1

Expand Down Expand Up @@ -243,7 +244,17 @@ class ModuleUpdater(logger.Logger):
fvs = dict(fvs[-1])
return fvs[CHASSIS_MODULE_INFO_OPERSTATUS_FIELD]
return ModuleBase.MODULE_STATUS_EMPTY


def get_module_admin_status(self, chassis_module_name):
config_db = daemon_base.db_connect("CONFIG_DB")
vtable = swsscommon.Table(config_db, CHASSIS_CFG_TABLE)
fvs = vtable.get(chassis_module_name)
if isinstance(fvs, list) and fvs[0] is True:
fvs = dict(fvs[-1])
return fvs[CHASSIS_MODULE_ADMIN_STATUS]
else:
return 'up'

def module_db_update(self):
notOnlineModules = []

Expand Down Expand Up @@ -302,12 +313,10 @@ class ModuleUpdater(logger.Logger):
elif prev_status != ModuleBase.MODULE_STATUS_ONLINE:
self.log_notice("Module {} is on-line!".format(key))

module_cfg_status = self.get_module_current_status(key)
if module_cfg_status == ModuleBase.MODULE_STATUS_EMPTY:
continue

#Only populate the related tables when the module configure is down
if module_cfg_status == 'down':
module_cfg_status = self.get_module_admin_status(key)

#Only populate the related tables when the module configure is up
if module_cfg_status != 'down':
for asic_id, asic in enumerate(module_info_dict[CHASSIS_MODULE_INFO_ASICS]):
asic_global_id, asic_pci_addr = asic
asic_key = "%s%s" % (CHASSIS_ASIC, asic_global_id)
Expand Down

0 comments on commit 2cd0832

Please sign in to comment.