diff options
author | Jenkins <jenkins@review.openstack.org> | 2017-06-19 15:26:33 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2017-06-19 15:26:33 +0000 |
commit | 96813ba2683552860c68d99931aa77cd6a0bf391 (patch) | |
tree | 6df1901592d7eb8a6aced93a247a7e13ef58ee82 /tripleo_heat_templates | |
parent | ab6080f94ddb1a0c4b7441064dd2728c98885ada (diff) | |
parent | f503d1b0e7fb9fe77e6fd1e71e08ca2d43427578 (diff) |
Merge "Support config dir for env generator input files"
Diffstat (limited to 'tripleo_heat_templates')
-rwxr-xr-x | tripleo_heat_templates/environment_generator.py | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/tripleo_heat_templates/environment_generator.py b/tripleo_heat_templates/environment_generator.py index e2f48720..659a7d57 100755 --- a/tripleo_heat_templates/environment_generator.py +++ b/tripleo_heat_templates/environment_generator.py @@ -165,24 +165,32 @@ def _generate_environment(input_env, parent_env=None): _generate_environment(e, env) -def generate_environments(config_file): - with open(config_file) as f: - config = yaml.safe_load(f) - for env in config['environments']: - _generate_environment(env) +def generate_environments(config_path): + if os.path.isdir(config_path): + config_files = os.listdir(config_path) + config_files = [os.path.join(config_path, i) for i in config_files + if os.path.splitext(i)[1] == '.yaml'] + else: + config_files = [config_path] + for config_file in config_files: + print('Reading environment definitions from %s' % config_file) + with open(config_file) as f: + config = yaml.safe_load(f) + for env in config['environments']: + _generate_environment(env) def usage(exit_code=1): - print('Usage: %s <filename.yaml>' % sys.argv[0]) + print('Usage: %s [<filename.yaml> | <directory>]' % sys.argv[0]) sys.exit(exit_code) def main(): try: - config_file = sys.argv[1] + config_path = sys.argv[1] except IndexError: usage() - generate_environments(config_file) + generate_environments(config_path) if __name__ == '__main__': |