From c8aba9a3e393cce194b918de780b6ad2f934fb15 Mon Sep 17 00:00:00 2001 From: Taoyu Li Date: Fri, 9 Mar 2018 00:47:32 +0000 Subject: [PATCH] Resolve PR comments --- files/image_config/updategraph/updategraph | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/files/image_config/updategraph/updategraph b/files/image_config/updategraph/updategraph index 729584fea237..446e700fa26c 100755 --- a/files/image_config/updategraph/updategraph +++ b/files/image_config/updategraph/updategraph @@ -1,14 +1,16 @@ #!/bin/bash +CONFIG_DB_INDEX=4 + reload_minigraph() { echo "Reloading minigraph..." if [ ! -f /etc/sonic/init_cfg.json ]; then echo "{}" > /etc/sonic/init_cfg.json fi - redis-cli -n 4 FLUSHDB + redis-cli -n $CONFIG_DB_INDEX FLUSHDB sonic-cfggen -H -m -j /etc/sonic/init_cfg.json --write-to-db - redis-cli -n 4 SET "CONFIG_DB_INITIALIZED" "1" + redis-cli -n $CONFIG_DB_INDEX SET "CONFIG_DB_INITIALIZED" "1" if [ -f /etc/sonic/acl.json ]; then acl-loader update full /etc/sonic/acl.json fi @@ -38,7 +40,7 @@ fi . /etc/sonic/updategraph.conf -if [ -f /tmp/firstboot ]; then +if [ -f /tmp/migration ]; then if [ "$enabled" = "true" ]; then echo "Use minigraph.xml from old system..." cp /etc/sonic/old_config/minigraph.xml /etc/sonic/ @@ -52,7 +54,7 @@ if [ -f /tmp/firstboot ]; then cp /etc/sonic/old_config/acl.json /etc/sonic/ fi reload_minigraph - sonic-cfggen -d --print_data > /etc/sonic/config_db.json + sonic-cfggen -d --print-data > /etc/sonic/config_db.json elif [ -f /etc/sonic/old_config/config_db.json ]; then echo "Use config_db.json from old system..." cp /etc/sonic/old_config/config_db.json /etc/sonic/ @@ -60,9 +62,9 @@ if [ -f /tmp/firstboot ]; then else copy_default_minigraph reload_minigraph - sonic-cfggen -d --print_data > /etc/sonic/config_db.json + sonic-cfggen -d --print-data > /etc/sonic/config_db.json fi - rm -f /tmp/firstboot + rm -f /tmp/migration sed -i "/enabled=/d" /etc/sonic/updategraph.conf echo "enabled=false" >> /etc/sonic/updategraph.conf exit 0 @@ -106,9 +108,9 @@ if [ "$src" = "dhcp" ]; then else cp -f /tmp/device_meta.json /etc/sonic/config_db.json fi - redis-cli -n 4 FLUSHDB + redis-cli -n $CONFIG_DB_INDEX FLUSHDB sonic-cfggen -j /etc/sonic/config_db.json --write-to-db - redis-cli -n 4 SET "CONFIG_DB_INITIALIZED" "1" + redis-cli -n $CONFIG_DB_INDEX SET "CONFIG_DB_INITIALIZED" "1" if [ "$dhcp_as_static" = "true" ]; then sed -i "/enabled=/d" /etc/sonic/updategraph.conf echo "enabled=false" >> /etc/sonic/updategraph.conf @@ -172,7 +174,7 @@ else fi reload_minigraph -sonic-cfggen -d --print_data > /etc/sonic/config_db.json +sonic-cfggen -d --print-data > /etc/sonic/config_db.json # Mark as disabled after graph is successfully downloaded sed -i "/enabled=/d" /etc/sonic/updategraph.conf