From bd097029f7ccf1b78f7636ae1860328bf5d00c64 Mon Sep 17 00:00:00 2001 From: ngocdo Date: Tue, 18 May 2021 21:51:44 -0700 Subject: [PATCH] Get asic PCI ID from CHASSIS_STATE_DB and update asic_id in CONFIG_DB Signed-off-by: ngocdo --- dockers/docker-orchagent/docker-init.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/dockers/docker-orchagent/docker-init.sh b/dockers/docker-orchagent/docker-init.sh index 5bf5bf2d06cf..d61c922a2e20 100755 --- a/dockers/docker-orchagent/docker-init.sh +++ b/dockers/docker-orchagent/docker-init.sh @@ -24,4 +24,21 @@ if [ "$VLAN" != "" ]; then cp /usr/share/sonic/templates/ndppd.conf /etc/supervisor/conf.d/ fi +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 + fi + fi + done +fi + exec /usr/local/bin/supervisord