Skip to content

Commit

Permalink
[chassis] update the asic_status.py to read from CHASSIS_FABRIC_ASIC_…
Browse files Browse the repository at this point in the history
…INFO_TABLE (#12576)

Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan [email protected]

Why I did it
Fixes #12575 and #12575

How I did it
In the PR sonic-net/sonic-platform-daemons#311 chassisd updates to CHASSIS_FABRIC_ASIC_INFO with the fabric asic info.
Updating the asic_status.py to read from the correct table.

How to verify it
test on chassis

Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <[email protected]>
  • Loading branch information
arlakshm authored Dec 8, 2022
1 parent d993444 commit 7db2725
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
28 changes: 16 additions & 12 deletions dockers/docker-orchagent/docker-init.j2
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ mkdir -p /etc/swss/config.d/
mkdir -p /etc/supervisor/
mkdir -p /etc/supervisor/conf.d/


CFGGEN_PARAMS=" \
-d \
{% if ENABLE_ASAN == "y" %}
Expand Down Expand Up @@ -48,21 +49,24 @@ 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_FABRIC_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
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 @@ -478,7 +478,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

0 comments on commit 7db2725

Please sign in to comment.