From a8e3d9745f31ea795e1b88e690364608e5462dd8 Mon Sep 17 00:00:00 2001 From: Taoyu Li Date: Wed, 21 Jun 2017 23:49:15 -0700 Subject: [PATCH] [sonic-cfggen]: Support multiple input yaml files with -y option (#729) --- src/sonic-config-engine/sonic-cfggen | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sonic-config-engine/sonic-cfggen b/src/sonic-config-engine/sonic-cfggen index 822f02d7fc..c0ce51d4bf 100755 --- a/src/sonic-config-engine/sonic-cfggen +++ b/src/sonic-config-engine/sonic-cfggen @@ -49,7 +49,7 @@ def main(): parser=argparse.ArgumentParser(description="Render configuration file from minigraph data and jinja2 template.") parser.add_argument("-m", "--minigraph", help="minigraph xml file") parser.add_argument("-p", "--port-config", help="port config file, used with -m") - parser.add_argument("-y", "--yaml", help="yaml file that contains addtional variables") + parser.add_argument("-y", "--yaml", help="yaml file that contains addtional variables", action='append', default=[]) parser.add_argument("-a", "--additional-data", help="addition data, in json string") group = parser.add_mutually_exclusive_group() group.add_argument("-t", "--template", help="render the data with the template file") @@ -79,8 +79,8 @@ def main(): else: data.update(parse_xml(minigraph)) - if args.yaml != None: - with open(args.yaml, 'r') as stream: + for yaml_file in args.yaml: + with open(yaml_file, 'r') as stream: additional_data = yaml.load(stream) data.update(additional_data)