[sonic-cfggen] Load JSON files before minigraph file (#4202)
If sonic-cfggen is passed the -m argument (to load the minigraph file) along with one or more -j <json_file> arguments, load the JSON files before loading the minigraph file. This ensures that the init_cfg.json file is loaded before the minigraph, therefore the minigraph can override any default configuration options specified in init_cfg.json. Currently, the behavior is reversed. Note: This is not an issue if loading loading multiple JSON files, because sonic-cfggen loads them in the left-to-right order they were specified on the command line, therefore providing flexibility for loading JSON files in a specific order. As long as init_cfg.json is specified before config_db.json, the values specified in config_db.json will take precedence.
This commit is contained in:
parent
d5c69bc9fc
commit
d19bba0ec0
@ -233,6 +233,10 @@ def main():
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
deep_update(data, {'PORT': ports})
|
deep_update(data, {'PORT': ports})
|
||||||
|
|
||||||
|
for json_file in args.json:
|
||||||
|
with open(json_file, 'r') as stream:
|
||||||
|
deep_update(data, FormatConverter.to_deserialized(json.load(stream)))
|
||||||
|
|
||||||
if args.minigraph != None:
|
if args.minigraph != None:
|
||||||
minigraph = args.minigraph
|
minigraph = args.minigraph
|
||||||
if platform:
|
if platform:
|
||||||
@ -254,10 +258,6 @@ def main():
|
|||||||
additional_data = yaml.load(stream)
|
additional_data = yaml.load(stream)
|
||||||
deep_update(data, FormatConverter.to_deserialized(additional_data))
|
deep_update(data, FormatConverter.to_deserialized(additional_data))
|
||||||
|
|
||||||
for json_file in args.json:
|
|
||||||
with open(json_file, 'r') as stream:
|
|
||||||
deep_update(data, FormatConverter.to_deserialized(json.load(stream)))
|
|
||||||
|
|
||||||
if args.additional_data != None:
|
if args.additional_data != None:
|
||||||
deep_update(data, json.loads(args.additional_data))
|
deep_update(data, json.loads(args.additional_data))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user