[chassis] update the asic_status.py to read from CHASSIS_FABRIC_ASIC_INFO_TABLE (#12576)

Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan arlakshm@microsoft.com

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 <arlakshm@microsoft.com>
This commit is contained in:
Arvindsrinivasan Lakshmi Narasimhan 2022-12-08 05:53:47 +00:00 committed by GitHub
parent d993444883
commit 7db272556e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 16 deletions

View File

@ -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" %}
@ -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

View File

@ -17,7 +17,7 @@ except ImportError as e:
# 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():
@ -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:

View File

@ -26,7 +26,7 @@ NEIGH_DEVICE_METADATA_CFG_DB_TABLE = 'DEVICE_NEIGHBOR_METADATA'
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
@ -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: