summaryrefslogtreecommitdiffstats
path: root/tripleo_heat_templates
diff options
context:
space:
mode:
authorBen Nemec <bnemec@redhat.com>2016-05-31 11:47:10 -0500
committerBen Nemec <bnemec@redhat.com>2017-06-12 15:02:50 -0500
commitf503d1b0e7fb9fe77e6fd1e71e08ca2d43427578 (patch)
tree124943345293b00d8225b7078176aa1be2703664 /tripleo_heat_templates
parent4e24c8cb6a1f65b1e5c764febfe96c2c465cfed1 (diff)
Support config dir for env generator input files
We're not going to want to list every single sample environment in a single file, so let's also take a directory and just read every yaml file in it. This commit adds support for that as well as some initial environments to demonstrate its use. Change-Id: If2c608f2a61fc5e16784ab594d23f1fa335e1d3c
Diffstat (limited to 'tripleo_heat_templates')
-rwxr-xr-xtripleo_heat_templates/environment_generator.py24
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__':