sonic-buildimage/dockers/docker-orchagent/swssconfig.sh
Jipan Yang dedd5624a0 Adapt to the new WARM_RESTART_TABLE table schema: change from restart… (#2083)
* Adapt to the new WARM_RESTART_TABLE table schema: change from restart_count to restore_count

Signed-off-by: Jipan Yang <jipan.yang@alibaba-inc.com>

* Update variable and function name to match restore_count name change

Signed-off-by: Jipan Yang <jipan.yang@alibaba-inc.com>

* Update swss submodule for warm restart schema change

Signed-off-by: Jipan Yang <jipan.yang@alibaba-inc.com>
2018-10-02 06:08:26 -07:00

62 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
function fast_reboot {
case "$(cat /proc/cmdline)" in
*fast-reboot*)
if [[ -f /fdb.json ]];
then
swssconfig /fdb.json
rm -f /fdb.json
fi
if [[ -f /arp.json ]];
then
swssconfig /arp.json
rm -f /arp.json
fi
if [[ -f /default_routes.json ]];
then
swssconfig /default_routes.json
rm -f /default_routes.json
fi
;;
*)
;;
esac
}
# Wait until swss.sh in the host system create file swss:/ready
until [[ -e /ready ]]; do
sleep 0.1;
done
rm -f /ready
# Restore FDB and ARP table ASAP
fast_reboot
HWSKU=`sonic-cfggen -d -v "DEVICE_METADATA['localhost']['hwsku']"`
# Don't load json config if system warm start or
# swss docker warm start is enabled, the data already exists in appDB.
SYSTEM_WARM_START=`redis-cli -n 4 hget "WARM_RESTART|system" enable`
SWSS_WARM_START=`redis-cli -n 4 hget "WARM_RESTART|swss" enable`
if [[ "$SYSTEM_WARM_START" == "true" ]] || [[ "$SWSS_WARM_START" == "true" ]]; then
# We have to make sure db data has not been flushed.
RESTORE_COUNT=`redis-cli -n 6 hget "WARM_RESTART_TABLE|orchagent" restore_count`
if [[ -n "$RESTORE_COUNT" ]] && [[ "$RESTORE_COUNT" != "0" ]]; then
exit 0
fi
fi
SWSSCONFIG_ARGS="00-copp.config.json ipinip.json ports.json switch.json "
for file in $SWSSCONFIG_ARGS; do
swssconfig /etc/swss/config.d/$file
sleep 1
done