For a given 'podN.yaml' file, check whether a file named
'idf-podN.yaml' exists in the same directory, and if it does,
pass its contents under the 'idf' dict key to the j2 template.
This assumes the contents of IDF yaml have a root 'idf' key.
Change-Id: I6c6f1b9f28c38989f8a6ed4a389c9a1da423d76d
Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
"""This module does blah blah."""
import argparse
import ipaddress
+import os
import yaml
from jinja2 import Environment, FileSystemLoader
with open(ARGS.yaml) as _:
DICT = yaml.safe_load(_)
+# If an installer descriptor file (IDF) exists, include it (temporary)
+IDF_PATH = '/idf-'.join(os.path.split(ARGS.yaml))
+if os.path.exists(IDF_PATH):
+ with open(IDF_PATH) as _:
+ IDF = yaml.safe_load(_)
+ DICT['idf'] = IDF['idf']
+
# Print dictionary generated from yaml (uncomment for debug)
# print(DICT)