Skip to content

Commit

Permalink
Vtysh support for multi asic (sonic-net#5479)
Browse files Browse the repository at this point in the history
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <[email protected]>
  • Loading branch information
arlakshm authored and santhosh-kt committed Feb 25, 2021
1 parent af03f4f commit af75ba5
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions dockers/docker-fpm-frr/base_image_files/vtysh
Original file line number Diff line number Diff line change
@@ -1,4 +1,37 @@
#!/bin/bash
# read SONiC immutable variables
[ -f /etc/sonic/sonic-environment ] && . /etc/sonic/sonic-environment

function help()
{
echo -e "Usage: $0 -n [0 to $(($NUM_ASIC-1))] [OPTION]... " 1>&2; exit 1;
}

DEV=""
PLATFORM=${PLATFORM:-`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform`}

# Parse the device specific asic conf file, if it exists
ASIC_CONF=/usr/share/sonic/device/$PLATFORM/asic.conf
[ -f $ASIC_CONF ] && . $ASIC_CONF

if [[ ($NUM_ASIC -gt 1) ]]; then
while getopts ":n:h:" opt; do
case "${opt}" in
h) help
;;
n) DEV=${OPTARG}
[ $DEV -lt $NUM_ASIC -a $DEV -ge 0 ] || help
;;
esac
done

if [ -z "${DEV}" ]; then
help
fi

# Skip the arguments -n <inst> while passing to docker command
shift 2
fi

# Determine whether stdout is on a terminal
if [ -t 1 ] ; then
Expand All @@ -7,10 +40,10 @@ if [ -t 1 ] ; then
TTY=$(tty)
function cleanup
{
docker exec -i bgp pkill -HUP -f "vtysh $TTY"
docker exec -i bgp$DEV pkill -HUP -f "vtysh $TTY"
}
trap cleanup HUP
docker exec -ti bgp vtysh "$TTY" "$@"
docker exec -ti bgp$DEV vtysh "$TTY" "$@"
else
docker exec -i bgp vtysh "$@"
docker exec -i bgp$DEV vtysh "$@"
fi

0 comments on commit af75ba5

Please sign in to comment.