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
This commit is contained in:
Saravanan KR 2018-11-30 15:27:09 +05:30
parent b6b4201be1
commit 435e846779

View File

@ -111,7 +111,9 @@ 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')
if os.path.exists(j2_excludes_path):
with open(j2_excludes_path) as role_data_file:
j2_excludes = yaml.safe_load(role_data_file)
@ -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):