Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[update graph] adapt to warm reboot scenario #2353

Merged
merged 2 commits into from
Dec 6, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 29 additions & 9 deletions files/image_config/updategraph/updategraph
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,29 @@ reload_minigraph()
pfcwd start_default
}

function copy_config_files()
{
for file in $@; do
if [ -f /etc/sonic/old_config/${file} ]; then
logger "Copying SONiC configuration ${file} ..."
cp /etc/sonic/old_config/${file} /etc/sonic/
yxieca marked this conversation as resolved.
Show resolved Hide resolved
else
logger "Missing SONiC configuration ${file} ..."
fi
done
}

function check_system_warm_boot()
{
SYSTEM_WARM_START=`/usr/bin/redis-cli -n 4 hget "WARM_RESTART|system" enable`
# SYSTEM_WARM_START could be empty, always make WARM_BOOT meaningful.
if [[ x"$SYSTEM_WARM_START" == x"true" ]]; then
WARM_BOOT="true"
else
WARM_BOOT="false"
fi
}


if [ ! -f /etc/sonic/updategraph.conf ]; then
echo "No updategraph.conf found, generating a default one."
Expand All @@ -26,21 +49,18 @@ fi

. /etc/sonic/updategraph.conf

check_system_warm_boot

if [ -f /tmp/pending_config_migration ]; then
if [ "$enabled" = "true" ]; then
copy_config_files minigraph.xml snmp.yml acl.json config_db.json
yxieca marked this conversation as resolved.
Show resolved Hide resolved
if [ x"${WARM_BOOT}" == x"true" ]; then
echo "Warm reboot detected..."
elif [ "$enabled" = "true" ]; then
echo "Use minigraph.xml from old system..."
cp /etc/sonic/old_config/minigraph.xml /etc/sonic/
if [ -f /etc/sonic/old_config/snmp.yml ]; then
cp /etc/sonic/old_config/snmp.yml /etc/sonic/
fi
if [ -f /etc/sonic/old_config/acl.json ]; then
cp /etc/sonic/old_config/acl.json /etc/sonic/
fi
reload_minigraph
sonic-cfggen -d --print-data > /etc/sonic/config_db.json
else
echo "Use config_db.json from old system..."
cp /etc/sonic/old_config/config_db.json /etc/sonic/
sonic-cfggen -j /etc/sonic/config_db.json --write-to-db
fi
rm -f /tmp/pending_config_migration
Expand Down