Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate config_db json file before config reload #3063

Closed
wants to merge 3 commits into from
Closed
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
12 changes: 12 additions & 0 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1515,6 +1515,18 @@ def reload(db, filename, yes, load_sysinfo, no_service_restart, force, file_form
click.echo("Input {} config file(s) separated by comma for multiple files ".format(num_cfg_file))
return

#Validate config_db.json file
Copy link
Contributor

Choose a reason for hiding this comment

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

Validate

Add one blank after #. I notice some old code does not follow, but let's align the new code with the code style.

if file_format == 'config_db':
file = DEFAULT_CONFIG_DB_FILE
Copy link
Contributor

Choose a reason for hiding this comment

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

file

file could be DEFAULT_CONFIG_DB_FILE or filename.
cfg_files could be split from filename or /etc/sonic/config_db{}.json.

Please check nearby code.

if os.path.exists(file):
command = [SONIC_CFGGEN_PATH, '-j', file]
clicommon.run_command(command)
for inst in range(0, num_cfg_file-1):
file = "/etc/sonic/config_db{}.json".format(inst)
Copy link
Contributor

Choose a reason for hiding this comment

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

@AnoopKamath is this tested on multi-asic platform?

if os.path.exists(file):
command = [SONIC_CFGGEN_PATH, '-j', file]
clicommon.run_command(command)
Copy link
Contributor

Choose a reason for hiding this comment

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

@AnoopKamath will this raise exception on failure?


#Stop services before config push
if not no_service_restart:
log.log_notice("'reload' stopping services...")
Expand Down
Loading