Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for the procedures for insertion/hot swap of Switch Fabric Module(SFM) by using "config chassis modules shutdown/startup" commands #475

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 26 additions & 11 deletions sonic-chassisd/scripts/chassisd
100644 → 100755
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 @@ -242,8 +243,18 @@ class ModuleUpdater(logger.Logger):
if isinstance(fvs, list) and fvs[0] is True:
fvs = dict(fvs[-1])
return fvs[CHASSIS_MODULE_INFO_OPERSTATUS_FIELD]
return ModuleBase.MODULE_STATUS_EMPTY

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,16 +313,20 @@ class ModuleUpdater(logger.Logger):
elif prev_status != ModuleBase.MODULE_STATUS_ONLINE:
self.log_notice("Module {} is on-line!".format(key))

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)
if not self._is_supervisor():
asic_key = "%s|%s" % (key, asic_key)
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':
JunhongMao marked this conversation as resolved.
Show resolved Hide resolved
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)
if not self._is_supervisor():
asic_key = "%s|%s" % (key, asic_key)

asic_fvs = swsscommon.FieldValuePairs([(CHASSIS_ASIC_PCI_ADDRESS_FIELD, asic_pci_addr),
(CHASSIS_MODULE_INFO_NAME_FIELD, key),
(CHASSIS_ASIC_ID_IN_MODULE_FIELD, str(asic_id))])
self.asic_table.set(asic_key, asic_fvs)
asic_fvs = swsscommon.FieldValuePairs([(CHASSIS_ASIC_PCI_ADDRESS_FIELD, asic_pci_addr),
(CHASSIS_MODULE_INFO_NAME_FIELD, key),
(CHASSIS_ASIC_ID_IN_MODULE_FIELD, str(asic_id))])
self.asic_table.set(asic_key, asic_fvs)

# In line card push the hostname of the module and num_asics to the chassis state db.
# The hostname is used as key to access chassis app db entries
Expand Down
Loading