Skip to content

[action] [PR:3984] Fix for #23205 [Smartswitch] Issues caused due to introduction of the chassisd/sonic-utiltiies changes for consecutive admin state changes #4015

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

Merged
merged 1 commit into from
Aug 5, 2025
Merged
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
22 changes: 14 additions & 8 deletions show/chassis_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from tabulate import tabulate
from swsscommon.swsscommon import SonicV2Connector
from utilities_common.chassis import is_smartswitch
from sonic_platform_base.module_base import ModuleBase

import utilities_common.cli as clicommon
from sonic_py_common import multi_asic
Expand Down Expand Up @@ -58,18 +59,21 @@ def status(db, chassis_module_name):
continue

data_dict = state_db.get_all(state_db.STATE_DB, key)
desc = data_dict[CHASSIS_MODULE_INFO_DESC_FIELD]
slot = data_dict[CHASSIS_MODULE_INFO_SLOT_FIELD]
oper_status = data_dict[CHASSIS_MODULE_INFO_OPERSTATUS_FIELD]
serial = data_dict[CHASSIS_MODULE_INFO_SERIAL_FIELD]

# Use default values if any field is missing
desc = data_dict.get(CHASSIS_MODULE_INFO_DESC_FIELD, 'N/A')
slot = data_dict.get(CHASSIS_MODULE_INFO_SLOT_FIELD, 'N/A')
oper_status = data_dict.get(CHASSIS_MODULE_INFO_OPERSTATUS_FIELD, ModuleBase.MODULE_STATUS_EMPTY)
serial = data_dict.get(CHASSIS_MODULE_INFO_SERIAL_FIELD, 'N/A')

# Determine admin_status
if is_smartswitch():
admin_status = 'down'
else:
admin_status = 'up'
config_data = chassis_cfg_table.get(key_list[1])
if config_data is not None:
admin_status = config_data.get(CHASSIS_MODULE_INFO_ADMINSTATUS_FIELD)
admin_status = config_data.get(CHASSIS_MODULE_INFO_ADMINSTATUS_FIELD, admin_status)

table.append((key_list[1], desc, slot, oper_status, admin_status, serial))

Expand Down Expand Up @@ -100,13 +104,15 @@ def midplane_status(chassis_module_name):
table = []
for key in natsorted(keys):
key_list = key.split('|')
if len(key_list) != 2: # error data in DB, log it and ignore
if len(key_list) != 2:
print('Warn: Invalid Key {} in {} table'.format(key, CHASSIS_MIDPLANE_INFO_TABLE))
continue

data_dict = state_db.get_all(state_db.STATE_DB, key)
ip = data_dict[CHASSIS_MIDPLANE_INFO_IP_FIELD]
access = data_dict[CHASSIS_MIDPLANE_INFO_ACCESS_FIELD]

# Defensive access with fallback defaults
ip = data_dict.get(CHASSIS_MIDPLANE_INFO_IP_FIELD, 'N/A')
access = data_dict.get(CHASSIS_MIDPLANE_INFO_ACCESS_FIELD, 'Unknown')

table.append((key_list[1], ip, access))

Expand Down
Loading