From cd85e2148b42aeae166fe17b68e54186e356bb5b Mon Sep 17 00:00:00 2001 From: Ying Xie Date: Wed, 2 Oct 2019 13:58:44 -0700 Subject: [PATCH] [updategraph] enhance update graph handling (#3549) - 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 --- files/image_config/updategraph/updategraph | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/files/image_config/updategraph/updategraph b/files/image_config/updategraph/updategraph index 5dc9c24d35..dd8314b012 100755 --- a/files/image_config/updategraph/updategraph +++ b/files/image_config/updategraph/updategraph @@ -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