Skip to content

Commit

Permalink
[multi-Asic] Add support for multi-asic to swssloglevel (#5316)
Browse files Browse the repository at this point in the history
* Support for multi-asic platform for swssloglevel command

admin@str-acs-1:~$ swssloglevel 
Usage: /usr/bin/swssloglevel -n [0 to 3] [OPTION]... 

* Update to use the env file to get the PLATFORM string.
  • Loading branch information
judyjoseph authored Sep 16, 2020
1 parent 6de9390 commit 642479f
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion dockers/docker-orchagent/base_image_files/swssloglevel
Original file line number Diff line number Diff line change
@@ -1,10 +1,44 @@
#!/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;
}

DOCKER_EXEC_FLAGS="i"

# Determine whether stdout is on a terminal
if [ -t 1 ] ; then
DOCKER_EXEC_FLAGS+="t"
fi

docker exec -$DOCKER_EXEC_FLAGS swss swssloglevel "$@"
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

docker exec -$DOCKER_EXEC_FLAGS swss$DEV swssloglevel "$@"

0 comments on commit 642479f

Please sign in to comment.