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

[202205][chassis] update the asic_status.py to read from CHASSIS_FABR… #12780

Merged
Merged
Show file tree
Hide file tree
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
28 changes: 15 additions & 13 deletions dockers/docker-orchagent/docker-init.j2
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,23 @@ if [ "$SUBTYPE" == "DualToR" ]; then
cp /usr/share/sonic/templates/tunnel_packet_handler.conf /etc/supervisor/conf.d/
fi

IS_SUPERVISOR=/etc/sonic/chassisdb.conf
USE_PCI_ID_IN_CHASSIS_STATE_DB=/usr/share/sonic/platform/use_pci_id_chassis
ASIC_ID="asic$NAMESPACE_ID"
if [ -f "$USE_PCI_ID_IN_CHASSIS_STATE_DB" ]; then
while true; do
PCI_ID=$(sonic-db-cli -s CHASSIS_STATE_DB HGET "CHASSIS_ASIC_TABLE|$ASIC_ID" asic_pci_address)
if [ -z "$PCI_ID" ]; then
sleep 3
else
# Update asic_id in CONFIG_DB, which is used by orchagent and fed to syncd
if [[ $PCI_ID == ????:??:??.? ]]; then
sonic-db-cli CONFIG_DB HSET 'DEVICE_METADATA|localhost' 'asic_id' ${PCI_ID#*:}
break
if [ -f "$IS_SUPERVISOR" ]; then
if [ -f "$USE_PCI_ID_IN_CHASSIS_STATE_DB" ]; then
while true; do
PCI_ID=$(sonic-db-cli -s CHASSIS_STATE_DB HGET "CHASSIS_ASIC_TABLE|$ASIC_ID" asic_pci_address)
Copy link
Contributor

@mlok-nokia mlok-nokia Nov 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original code applies to both IMM and supervisor. But the new code is changed to only applicable to the supervisor card. If it is for supervisor card, the key CHASSIS_ASIC_TABLE should be CHASSIS_FABRIC_ASIC_TABLE. But this PR requires the sonic-net/sonic-platform-daemons#311

if [ -z "$PCI_ID" ]; then
sleep 3
else
# Update asic_id in CONFIG_DB, which is used by orchagent and fed to syncd
if [[ $PCI_ID == ????:??:??.? ]]; then
sonic-db-cli CONFIG_DB HSET 'DEVICE_METADATA|localhost' 'asic_id' ${PCI_ID#*:}
break
fi
fi
fi
done
done
fi
fi

exec /usr/local/bin/supervisord
4 changes: 2 additions & 2 deletions files/scripts/asic_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Constants ====================================================================
#
SYSLOG_IDENTIFIER = 'asic_status.py'
CHASSIS_ASIC_INFO_TABLE = 'CHASSIS_ASIC_TABLE'
CHASSIS_FABRIC_ASIC_INFO_TABLE = 'CHASSIS_FABRIC_ASIC_TABLE'
SELECT_TIMEOUT_MSECS = 5000

def main():
Expand All @@ -40,7 +40,7 @@ def main():
state_db = daemon_base.db_connect("CHASSIS_STATE_DB")

sel = swsscommon.Select()
sst = swsscommon.SubscriberStateTable(state_db, CHASSIS_ASIC_INFO_TABLE)
sst = swsscommon.SubscriberStateTable(state_db, CHASSIS_FABRIC_ASIC_INFO_TABLE)
sel.addSelectable(sst)

while True:
Expand Down
4 changes: 2 additions & 2 deletions src/sonic-py-common/sonic_py_common/multi_asic.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
DEFAULT_NAMESPACE = ''
PORT_ROLE = 'role'
CHASSIS_STATE_DB='CHASSIS_STATE_DB'
CHASSIS_ASIC_INFO_TABLE='CHASSIS_ASIC_TABLE'
CHASSIS_FABRIC_ASIC_INFO_TABLE='CHASSIS_FABRIC_ASIC_TABLE'

# Dictionary to cache config_db connection handle per namespace
# to prevent duplicate connections from being opened
Expand Down Expand Up @@ -479,7 +479,7 @@ def get_asic_presence_list():
# Get asic list from CHASSIS_ASIC_TABLE which lists only the asics
# present based on Fabric card detection by the platform.
db = swsscommon.DBConnector(CHASSIS_STATE_DB, 0, True)
asic_table = swsscommon.Table(db, CHASSIS_ASIC_INFO_TABLE)
asic_table = swsscommon.Table(db, CHASSIS_FABRIC_ASIC_INFO_TABLE)
if asic_table:
asics_presence_list = list(asic_table.getKeys())
for asic in asics_presence_list:
Expand Down