[sonic-cfggen] Loading the configuration from init_cfg.json and then from config_db.json (#4148)
This commit is contained in:
parent
a8baca0d6e
commit
8e36068237
@ -106,10 +106,14 @@ function postStartAction()
|
|||||||
if [[ ("$BOOT_TYPE" == "warm" || "$BOOT_TYPE" == "fastfast") && -f $WARM_DIR/dump.rdb ]]; then
|
if [[ ("$BOOT_TYPE" == "warm" || "$BOOT_TYPE" == "fastfast") && -f $WARM_DIR/dump.rdb ]]; then
|
||||||
rm -f $WARM_DIR/dump.rdb
|
rm -f $WARM_DIR/dump.rdb
|
||||||
else
|
else
|
||||||
# If there is a config db dump file, load it
|
# If there is a config_db.json dump file, load it.
|
||||||
if [ -r /etc/sonic/config_db.json ]; then
|
if [ -r /etc/sonic/config_db.json ]; then
|
||||||
|
if [ -r /etc/sonic/init_cfg.json ]; then
|
||||||
|
sonic-cfggen -j /etc/sonic/init_cfg.json -j /etc/sonic/config_db.json --write-to-db
|
||||||
|
else
|
||||||
sonic-cfggen -j /etc/sonic/config_db.json --write-to-db
|
sonic-cfggen -j /etc/sonic/config_db.json --write-to-db
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "$BOOT_TYPE" == "fast" ]]; then
|
if [[ "$BOOT_TYPE" == "fast" ]]; then
|
||||||
# set the key to expire in 3 minutes
|
# set the key to expire in 3 minutes
|
||||||
|
@ -5,9 +5,13 @@ until [[ $(redis-cli ping | grep -c PONG) -gt 0 ]]; do
|
|||||||
sleep 1;
|
sleep 1;
|
||||||
done
|
done
|
||||||
|
|
||||||
# If there is a config db dump file, load it
|
# If there is a config_db.json dump file, load it.
|
||||||
if [ -r /etc/sonic/config_db.json ]; then
|
if [ -r /etc/sonic/config_db.json ]; then
|
||||||
|
if [ -r /etc/sonic/init_cfg.json ]; then
|
||||||
|
sonic-cfggen -j /etc/sonic/init_cfg.json -j /etc/sonic/config_db.json --write-to-db
|
||||||
|
else
|
||||||
sonic-cfggen -j /etc/sonic/config_db.json --write-to-db
|
sonic-cfggen -j /etc/sonic/config_db.json --write-to-db
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sonic-db-cli CONFIG_DB SET "CONFIG_DB_INITIALIZED" "1"
|
sonic-db-cli CONFIG_DB SET "CONFIG_DB_INITIALIZED" "1"
|
||||||
|
@ -11,7 +11,7 @@ SYSTEM_MAC_ADDRESS=$(ip link show eth0 | grep ether | awk '{print $2}')
|
|||||||
sonic-cfggen -a '{"DEVICE_METADATA":{"localhost": {"mac": "'$SYSTEM_MAC_ADDRESS'"}}}' --print-data > /etc/sonic/init_cfg.json
|
sonic-cfggen -a '{"DEVICE_METADATA":{"localhost": {"mac": "'$SYSTEM_MAC_ADDRESS'"}}}' --print-data > /etc/sonic/init_cfg.json
|
||||||
|
|
||||||
if [ -f /etc/sonic/config_db.json ]; then
|
if [ -f /etc/sonic/config_db.json ]; then
|
||||||
sonic-cfggen -j /etc/sonic/config_db.json -j /etc/sonic/init_cfg.json --print-data > /tmp/config_db.json
|
sonic-cfggen -j /etc/sonic/init_cfg.json -j /etc/sonic/config_db.json --print-data > /tmp/config_db.json
|
||||||
mv /tmp/config_db.json /etc/sonic/config_db.json
|
mv /tmp/config_db.json /etc/sonic/config_db.json
|
||||||
else
|
else
|
||||||
sonic-cfggen -j /etc/sonic/init_cfg.json --print-data > /etc/sonic/config_db.json
|
sonic-cfggen -j /etc/sonic/init_cfg.json --print-data > /etc/sonic/config_db.json
|
||||||
|
@ -13,7 +13,7 @@ SYSTEM_MAC_ADDRESS=$(ip link show eth0 | grep ether | awk '{print $2}')
|
|||||||
sonic-cfggen -a '{"DEVICE_METADATA":{"localhost": {"mac": "'$SYSTEM_MAC_ADDRESS'"}}}' --print-data > /etc/sonic/init_cfg.json
|
sonic-cfggen -a '{"DEVICE_METADATA":{"localhost": {"mac": "'$SYSTEM_MAC_ADDRESS'"}}}' --print-data > /etc/sonic/init_cfg.json
|
||||||
|
|
||||||
if [ -f /etc/sonic/config_db.json ]; then
|
if [ -f /etc/sonic/config_db.json ]; then
|
||||||
sonic-cfggen -j /etc/sonic/config_db.json -j /etc/sonic/init_cfg.json --print-data > /tmp/config_db.json
|
sonic-cfggen -j /etc/sonic/init_cfg.json -j /etc/sonic/config_db.json --print-data > /tmp/config_db.json
|
||||||
mv /tmp/config_db.json /etc/sonic/config_db.json
|
mv /tmp/config_db.json /etc/sonic/config_db.json
|
||||||
else
|
else
|
||||||
# generate and merge buffers configuration into config file
|
# generate and merge buffers configuration into config file
|
||||||
|
Loading…
Reference in New Issue
Block a user