[multi-asic][vs]: Update topology script to retrieve hwsku from minigraph (#6219)

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.
This commit is contained in:
SuvarnaMeenakshi 2021-02-18 22:02:29 -08:00 committed by GitHub
parent 2fc37dd767
commit 5a49a0f499
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 14 deletions

View File

@ -8,10 +8,10 @@ NUM_INTERFACES_PER_ASIC=32
start () { start () {
# Move external links into assigned frontend namespaces # Move external links into assigned frontend namespaces
# eth0 - eth15: asic2 # eth1 - eth16: asic0
# eth16 - eth31: asic3 # eth17 - eth32: asic1
# eth32 - eth47: asic4 # eth33 - eth48: asic2
# eth48 - eth63: asic5 # eth49 - eth64: asic3
for ASIC in `seq $FIRST_FRONTEND_ASIC $LAST_FRONTEND_ASIC`; do for ASIC in `seq $FIRST_FRONTEND_ASIC $LAST_FRONTEND_ASIC`; do
for NUM in `seq 1 16`; do for NUM in `seq 1 16`; do
ORIG="eth$((16 * $ASIC + $NUM))" ORIG="eth$((16 * $ASIC + $NUM))"
@ -22,6 +22,7 @@ start () {
ip link set dev $ORIG name $TEMP # rename to prevent conflicts before renaming in new namespace ip link set dev $ORIG name $TEMP # rename to prevent conflicts before renaming in new namespace
ip link set dev $TEMP netns asic$ASIC ip link set dev $TEMP netns asic$ASIC
sudo ip netns exec asic$ASIC ip link set $TEMP name $NEW # rename to final interface name sudo ip netns exec asic$ASIC ip link set $TEMP name $NEW # rename to final interface name
sudo ip netns exec asic$ASIC ip link set dev $NEW mtu 9100
sudo ip netns exec asic$ASIC ip link set $NEW up sudo ip netns exec asic$ASIC ip link set $NEW up
done done
done done
@ -43,7 +44,9 @@ start () {
sudo ip netns exec asic$BACKEND ip link set $TEMP_BACK name $BACK_NAME sudo ip netns exec asic$BACKEND ip link set $TEMP_BACK name $BACK_NAME
sudo ip netns exec asic$FRONTEND ip link set $TEMP_FRONT name $FRONT_NAME sudo ip netns exec asic$FRONTEND ip link set $TEMP_FRONT name $FRONT_NAME
sudo ip netns exec asic$BACKEND ip link set dev $BACK_NAME mtu 9100
sudo ip netns exec asic$BACKEND ip link set $BACK_NAME up sudo ip netns exec asic$BACKEND ip link set $BACK_NAME up
sudo ip netns exec asic$FRONTEND ip link set dev $FRONT_NAME mtu 9100
sudo ip netns exec asic$FRONTEND ip link set $FRONT_NAME up sudo ip netns exec asic$FRONTEND ip link set $FRONT_NAME up
done done
done done
@ -54,8 +57,8 @@ stop() {
for ASIC in `seq $FIRST_FRONTEND_ASIC $LAST_FRONTEND_ASIC`; do for ASIC in `seq $FIRST_FRONTEND_ASIC $LAST_FRONTEND_ASIC`; do
for NUM in `seq 1 16`; do for NUM in `seq 1 16`; do
TEMP="eth999" TEMP="eth999"
OLD="eth$((16 * $ASIC + $NUM))" OLD="eth$(($NUM))"
NAME="eth$((16 * $ASIC + $NUM - 1))" NAME="eth$((16 * $ASIC + $NUM))"
sudo ip netns exec asic$ASIC ip link set dev $OLD down sudo ip netns exec asic$ASIC ip link set dev $OLD down
sudo ip netns exec asic$ASIC ip link set dev $OLD name $TEMP sudo ip netns exec asic$ASIC ip link set dev $OLD name $TEMP
sudo ip netns exec asic$ASIC ip link set dev $TEMP netns 1 sudo ip netns exec asic$ASIC ip link set dev $TEMP netns 1

View File

@ -1,21 +1,49 @@
#!/bin/bash #!/bin/bash
# This script is invoked by topology.service only # This script is invoked by topology.service only
# for multi-asic virtual platform. For multi-asic platform # for multi-asic virtual platform. For multi-asic platform
# multiple Database instances are present # multiple Database instances are present
# and HWKSU information is retrieved from first database instance. # 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() { start() {
TOPOLOGY_SCRIPT="topology.sh" TOPOLOGY_SCRIPT="topology.sh"
PLATFORM=${PLATFORM:-`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform`} PLATFORM=`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform`
HWSKU=${HWSKU:-`sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["hwsku"]'`} HWSKU=`get_hwsku`
/usr/share/sonic/device/$PLATFORM/$HWSKU/$TOPOLOGY_SCRIPT start if [[ $HWSKU != "" ]]; then
/usr/share/sonic/device/$PLATFORM/$HWSKU/$TOPOLOGY_SCRIPT start
else
echo "Failed to get HWSKU"
exit 1
fi
} }
stop() { stop() {
TOPOLOGY_SCRIPT="topology.sh" TOPOLOGY_SCRIPT="topology.sh"
PLATFORM=${PLATFORM:-`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform`} PLATFORM=`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform`
HWSKU=${HWSKU:-`sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["hwsku"]'`} HWSKU=`get_hwsku`
usr/share/sonic/device/$PLATFORM/$HWSKU/$TOPOLOGY_SCRIPT stop 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 # read SONiC immutable variables