From 435e846779526b3e56a67537d7280b614068d190 Mon Sep 17 00:00:00 2001 From: Saravanan KR Date: Fri, 30 Nov 2018 15:27:09 +0530 Subject: [PATCH] Process the templates even if j2_excludes file is not present It is possible to use the process_templates script to generate the user's jinja templates based on role and network data. But the script expects the presence of j2_excludes file. Making it as optional, allows users to generate templates in user's template directory itself, like $ /usr/share/openstack-tripleo-heat-templates/tools/process-templates.py \ -p ~/templates/ \ -r ~/templates/roles_data.yaml \ -n ~/templates/network_data.yaml Closes-Bug: #1806351 Change-Id: I375cd9ff9b40bbdad34d0732ec8abd25fbdde46e --- tools/process-templates.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/process-templates.py b/tools/process-templates.py index 3ef6389c35..4e6eaf9bd6 100755 --- a/tools/process-templates.py +++ b/tools/process-templates.py @@ -111,9 +111,11 @@ def process_templates(template_path, role_data_path, output_dir, with open(network_data_path) as network_data_file: network_data = yaml.safe_load(network_data_file) + j2_excludes = {} j2_excludes_path = os.path.join(template_path, 'j2_excludes.yaml') - with open(j2_excludes_path) as role_data_file: - j2_excludes = yaml.safe_load(role_data_file) + if os.path.exists(j2_excludes_path): + with open(j2_excludes_path) as role_data_file: + j2_excludes = yaml.safe_load(role_data_file) if output_dir and not os.path.isdir(output_dir): if os.path.exists(output_dir): @@ -135,7 +137,7 @@ def process_templates(template_path, role_data_path, output_dir, print("skipping %s network: network is disabled" % n.get('name')) excl_templates = ['%s/%s' % (template_path, e) - for e in j2_excludes.get('name')] + for e in j2_excludes.get('name', [])] if os.path.isdir(template_path): for subdir, dirs, files in os.walk(template_path):