5a49a0f499
Update topology script to retrieve hwsku from minigraph if hwsku information is not available in config_db. Fix clean up of interfaces in msft_multi_asic_vs hwsku topology script. - Why I did it When bringing up multi-asic VS switch, topology service is started during boot up. Topology service starts a shell script which runs the topology script present in /usr/share/sonic/device// directory. To invoke hwsku specific script, the topology script tries to retrieve hwsku information from config_db. During initial boot up config_db might not be populated. In order to start topology service before config_db is updated, update topology script to get hwsku information from minigraph.xml if it is available. This will be helpful to bring up multi-asic VS testbed by loading minigraph and starting topology service. - How I did it Update topology.sh script to retrieve hwsku information from minigraph.xml. Fix clean up function on msft_multi_asic_vs toplogy script. - How to verify it single-asic VS - no change; topology service is only enabled for multi-asic VS. multi-asic VS - Bring up multi-asic VS image, copy minigraph to vs image, start topology service. Topology service should be successful. to test clean up function fix, start topology service - make sure interfaces are created and moved to the right namespaces. stop topology service - make sure namespace do not have any interface and all front end interfaces are present in default namespace.
60 lines
1.7 KiB
Bash
Executable File
60 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
# This script is invoked by topology.service only
|
|
# for multi-asic virtual platform. For multi-asic platform
|
|
# multiple Database instances are present
|
|
# and HWKSU information is retrieved from first database instance.
|
|
#
|
|
|
|
get_hwsku() {
|
|
# Get HWSKU from config_db. If HWSKU is not available in config_db
|
|
# get HWSKU from minigraph.xml if minigraph file exists.
|
|
HWSKU=`sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["hwsku"]' 2>&1`
|
|
if [[ $? -ne 0 || $HWSKU == "" ]]; then
|
|
if [[ -f "/etc/sonic/minigraph.xml" ]]; then
|
|
HWSKU=`sonic-cfggen -m /etc/sonic/minigraph.xml -v "DEVICE_METADATA['localhost']['hwsku']" 2>&1`
|
|
if [[ $? -ne 0 || $HWSKU == "" ]]; then
|
|
HWSKU=""
|
|
fi
|
|
else
|
|
HWSKU=""
|
|
fi
|
|
fi
|
|
echo "${HWSKU}"
|
|
}
|
|
|
|
start() {
|
|
TOPOLOGY_SCRIPT="topology.sh"
|
|
PLATFORM=`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform`
|
|
HWSKU=`get_hwsku`
|
|
if [[ $HWSKU != "" ]]; then
|
|
/usr/share/sonic/device/$PLATFORM/$HWSKU/$TOPOLOGY_SCRIPT start
|
|
else
|
|
echo "Failed to get HWSKU"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
stop() {
|
|
TOPOLOGY_SCRIPT="topology.sh"
|
|
PLATFORM=`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform`
|
|
HWSKU=`get_hwsku`
|
|
if [[ $HWSKU != "" ]]; then
|
|
/usr/share/sonic/device/$PLATFORM/$HWSKU/$TOPOLOGY_SCRIPT stop
|
|
else
|
|
echo "Failed to get HWSKU"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# read SONiC immutable variables
|
|
[ -f /etc/sonic/sonic-environment ] && . /etc/sonic/sonic-environment
|
|
|
|
case "$1" in
|
|
start|stop)
|
|
$1
|
|
;;
|
|
*)
|
|
echo "Usage: $0 {start|stop}"
|
|
;;
|
|
esac
|