Skip to content

Commit

Permalink
[updategraph] enhance update graph handling (#3549)
Browse files Browse the repository at this point in the history
- after reloading minigraph, write latest version string in the DB.
- if old config_db.json file exists, use it and migrate to latest version.
- only reload minigraph when config_db.json doesn't exist and minigraph
  exists.

Signed-off-by: Ying Xie <ying.xie@microsoft.com>
  • Loading branch information
yxieca committed Oct 2, 2019
1 parent e4f8a39 commit 37b7882
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions files/image_config/updategraph/updategraph
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,20 @@ if [ -f /tmp/pending_config_migration ]; then
copy_config_files_and_directories $copy_list
if [ x"${WARM_BOOT}" == x"true" ]; then
echo "Warm reboot detected..."
elif [ "$enabled" = "true" ]; then
elif [ -r /etc/sonic/config_db.json ]; then
echo "Use config_db.json from old system..."
sonic-cfggen -j /etc/sonic/config_db.json --write-to-db

if [[ -x /usr/bin/db_migrator.py ]]; then
# Migrate the DB to the latest schema version if needed
/usr/bin/db_migrator.py -o migrate
fi
elif [ -r /etc/sonic/minigraph.xml ]; then
echo "Use minigraph.xml from old system..."
reload_minigraph
sonic-cfggen -d --print-data > /etc/sonic/config_db.json
else
echo "Use config_db.json from old system..."
sonic-cfggen -j /etc/sonic/config_db.json --write-to-db
echo "Didn't found neither config_db.json nor minigraph.xml ..."
fi
rm -f /tmp/pending_config_migration
sed -i "/enabled=/d" /etc/sonic/updategraph.conf
Expand Down

0 comments on commit 37b7882

Please sign in to comment.