Skip to content
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
36 changes: 6 additions & 30 deletions files/image_config/config-setup/config-setup
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,13 @@ reload_minigraph()
}

# Reload exisitng config db file on disk
# Usage: reload_configdb <config_file>
reload_configdb()
{
CONFIG_FILE=${1}

echo "Reloading existing config db..."
config reload -y -n
config reload ${CONFIG_FILE} -y -n
}
# Restore SONiC configuration from a backup copy
function copy_config_files_and_directories()
Expand Down Expand Up @@ -171,33 +174,6 @@ ztp_is_enabled()
return $rv
}

# Load requested SONiC configuration into config DB and initialize it
# Usage: load_config <config_file>
#
#
load_config()
{
CONFIG_FILE=${1}
if [ "${CONFIG_FILE}" = "" ]; then
return 1
fi

sonic-db-cli CONFIG_DB FLUSHDB
sonic-cfggen -j ${CONFIG_FILE} --write-to-db
if [ $? -ne 0 ]; then
return $?
fi

if [[ -x /usr/local/bin/db_migrator.py ]]; then
# Migrate the DB to the latest schema version if needed
/usr/local/bin/db_migrator.py -o migrate
fi

sonic-db-cli CONFIG_DB SET "CONFIG_DB_INITIALIZED" "1"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we have a dependency on this CONFIG_DB_INITIALIZED elsewhere. Do we not need this?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return 0
}


# Generate requested SONiC configuration and save it as destination file
# Usage: generate_config < factory | ztp > <destination_file>
#
Expand Down Expand Up @@ -249,14 +225,14 @@ do_config_initialization()
if ! ztp_is_enabled ; then
echo "No configuration detected, generating factory default configuration..."
generate_config factory ${CONFIG_DB_JSON}
load_config ${CONFIG_DB_JSON}
reload_configdb ${CONFIG_DB_JSON}
fi
fi

if ztp_is_enabled ; then
echo "No configuration detected, initiating zero touch provisioning..."
generate_config ztp ${TMP_ZTP_CONFIG_DB_JSON}
load_config ${TMP_ZTP_CONFIG_DB_JSON}
reload_configdb ${TMP_ZTP_CONFIG_DB_JSON}
rm -f ${TMP_ZTP_CONFIG_DB_JSON}
fi

Expand Down