Skip to content

Commit

Permalink
Add peer gbsyncd if gearbox exists
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyzhai committed Apr 8, 2022
1 parent ced22db commit b299b7c
Showing 1 changed file with 40 additions and 20 deletions.
60 changes: 40 additions & 20 deletions files/scripts/swss.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,13 @@ start_peer_and_dependent_services() {
check_warm_boot

if [[ x"$WARM_BOOT" != x"true" ]]; then
if [[ ! -z $DEV ]]; then
/bin/systemctl start ${PEER}@$DEV
else
/bin/systemctl start ${PEER}
fi
for peer in ${PEER}; do
if [[ ! -z $DEV ]]; then
/bin/systemctl start ${peer}@$DEV
else
/bin/systemctl start ${peer}
fi
done
for dep in ${DEPENDENT}; do
/bin/systemctl start ${dep}
done
Expand All @@ -143,11 +145,13 @@ stop_peer_and_dependent_services() {
for dep in ${DEPENDENT}; do
/bin/systemctl stop ${dep}
done
if [[ ! -z $DEV ]]; then
/bin/systemctl stop ${PEER}@$DEV
else
/bin/systemctl stop ${PEER}
fi
for peer in ${PEER}; do
if [[ ! -z $DEV ]]; then
/bin/systemctl stop ${peer}@$DEV
else
/bin/systemctl stop ${peer}
fi
done
fi
}

Expand Down Expand Up @@ -207,11 +211,13 @@ wait() {
# NOTE: This assumes Docker containers share the same names as their
# corresponding services
for SECS in {1..60}; do
if [[ ! -z $DEV ]]; then
RUNNING=$(docker inspect -f '{{.State.Running}}' ${PEER}$DEV)
else
RUNNING=$(docker inspect -f '{{.State.Running}}' ${PEER})
fi
for peer in ${PEER}; do
if [[ ! -z $DEV ]]; then
RUNNING=$(docker inspect -f '{{.State.Running}}' ${peer}$DEV)
else
RUNNING=$(docker inspect -f '{{.State.Running}}' ${peer})
fi
done
ALL_DEPS_RUNNING=true
for dep in ${MULTI_INST_DEPENDENT}; do
if [[ ! -z $DEV ]]; then
Expand Down Expand Up @@ -242,11 +248,13 @@ wait() {
fi
done

if [[ ! -z $DEV ]]; then
/usr/bin/docker-wait-any -s ${SERVICE}$DEV -d ${PEER}$DEV ${ALL_DEPS}
else
/usr/bin/docker-wait-any -s ${SERVICE} -d ${PEER} ${ALL_DEPS}
fi
for peer in ${PEER}; do
if [[ ! -z $DEV ]]; then
/usr/bin/docker-wait-any -s ${SERVICE}$DEV -d ${peer}$DEV ${ALL_DEPS}
else
/usr/bin/docker-wait-any -s ${SERVICE} -d ${peer} ${ALL_DEPS}
fi
done
}

stop() {
Expand Down Expand Up @@ -283,6 +291,17 @@ stop() {
stop_peer_and_dependent_services
}

function check_peer_gbsyncd()
{
PLATFORM=`$SONIC_DB_CLI CONFIG_DB hget 'DEVICE_METADATA|localhost' platform`
HWSKU=`$SONIC_DB_CLI CONFIG_DB hget 'DEVICE_METADATA|localhost' hwsku`
GEARBOX_CONFIG=/usr/share/sonic/device/$PLATFORM/$HWSKU/$DEV/gearbox_config.json

if [ -f $GEARBOX_CONFIG ]; then
PEER="$PEER gbsyncd"
fi
}

if [ "$DEV" ]; then
NET_NS="$NAMESPACE_PREFIX$DEV" #name of the network namespace
SONIC_DB_CLI="sonic-db-cli -n $NET_NS"
Expand All @@ -291,6 +310,7 @@ else
SONIC_DB_CLI="sonic-db-cli"
fi

check_peer_gbsyncd
read_dependent_services

case "$1" in
Expand Down

0 comments on commit b299b7c

Please sign in to comment.