- try:
- env = Environment()
- ast = env.parse(cloud_init_content)
- mandatory_vars = meta.find_undeclared_variables(ast)
- if mandatory_vars:
- for var in mandatory_vars:
- if not additionalParams or var not in additionalParams.keys():
- raise LcmException("Variable '{}' defined in vnfd[id={}] vdu[id={}] cloud-init or "
- "cloud-init-file, must be provided in the instantiation parameters "
- "inside the 'additionalParamsForVnf' block".format(var, vnfd["id"],
- vdu["id"]))
- template = Template(cloud_init_content)
- cloud_init_content = template.render(additionalParams)
- except (TemplateError, TemplateNotFound, TemplateSyntaxError) as e:
- raise LcmException("Error in jinja2 template: {}".format(e))
+ else:
+ continue
+
+ env = Environment()
+ ast = env.parse(cloud_init_content)
+ mandatory_vars = meta.find_undeclared_variables(ast)
+ if mandatory_vars:
+ for var in mandatory_vars:
+ if not additionalParams or var not in additionalParams.keys():
+ raise LcmException("Variable '{}' defined at vnfd[id={}]:vdu[id={}]:cloud-init/cloud-init-"
+ "file, must be provided in the instantiation parameters inside the "
+ "'additionalParamsForVnf' block".format(var, vnfd["id"], vdu["id"]))
+ template = Template(cloud_init_content)
+ cloud_init_content = template.render(additionalParams)