diff options
author | Steven Hardy <shardy@redhat.com> | 2017-05-31 11:22:49 +0100 |
---|---|---|
committer | Steven Hardy <shardy@redhat.com> | 2017-07-04 14:18:50 +0100 |
commit | 6a2f8bd5020be473c606383d163f24968ecb8139 (patch) | |
tree | 21c16a1cbb00c083fd2071429ab43c77492465f7 /tools | |
parent | b5081b67e5f5a6c88c149f0cd13e0053494f6d60 (diff) |
Convert role templates to consume roles_data map
Currently we only consume the name with a special-case
for the disable constraints boolean, but it will be more
flexible if we consume the whole roles_data mapping for
each role, so that e.g composable networks and other
per-role customizations can be expressed in these
templates
Partially-Implements: blueprint composable-networks
Depends-On: Id1249b78b3dd87e91d572ffa31b7a541f3cde2c7
Change-Id: I355534ec456479944f66106e957404a660d8f2d2
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/process-templates.py | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/tools/process-templates.py b/tools/process-templates.py index 69ed96a6..c7d5ed9e 100755 --- a/tools/process-templates.py +++ b/tools/process-templates.py @@ -138,19 +138,31 @@ def process_templates(template_path, role_data_path, output_dir, print("jinja2 rendering roles %s" % "," .join(role_names)) for role in role_names: - j2_data = {'role': role} - # (dprince) For the undercloud installer we don't - # want to have heat check nova/glance API's - if r_map[role].get('disable_constraints', False): - j2_data['disable_constraints'] = True + j2_data = {'role': r_map[role]} out_f = "-".join( [role.lower(), os.path.basename(f).replace('.role.j2.yaml', '.yaml')]) out_f_path = os.path.join(out_dir, out_f) if not (out_f_path in excl_templates): - _j2_render_to_file(template_data, j2_data, - out_f_path, overwrite) + if '{{role.name}}' in template_data: + j2_data = {'role': r_map[role]} + _j2_render_to_file(template_data, j2_data, + out_f_path, overwrite) + else: + # Backwards compatibility with templates + # that specify {{role}} vs {{role.name}} + j2_data = {'role': role} + # (dprince) For the undercloud installer we + # don'twant to have heat check nova/glance + # API's + if r_map[role].get('disable_constraints', + False): + j2_data['disable_constraints'] = True + _j2_render_to_file( + template_data,j2_data, + out_f_path, overwrite) + else: print('skipping rendering of %s' % out_f_path) elif f.endswith('.j2.yaml'): |