I have a yaml template (lets call it main.yaml) which calls another yaml template like below. the VM1.yaml template is a normal template that creates another stack. (It will be like a nested template)
main.yaml
resources:
VM1:
type: OS::Heat::Stack
properties:
template: {get_file: vm/VM1.yaml}
parameters:
name: { list_join: ["_", [ { get_param: 'OS::stack_name' }, "VM1"]] }
Below is the folder structure
vm/parameter.yaml => this is a parameter file where I am passing the parameters.
template_file = 'MAIN_VM1_MOUNTED.yaml'
template = open(template_file, 'r')
stack_name = 'HeenaStack' + sys.argv[5]
heat_parameters = open('vm/parameter.yaml')
temp_params = yaml.load(heat_parameters)
heat_parameters.close()
try:
#hc.stacks.create(stack_name=stack_name, template=template.read(), parameters=temp_params["parameters"])
stackCreate = hc.stacks.create(stack_name=stack_name, template=template.read(), parameters=temp_params["parameters"])
print("Stack Created successfully", "Stack ID:", str(hc.stacks.get(stack_name).id))
Whn I am running openstack stack create with this nested yaml templates, the stack gets created successfully. The same is not happening in python. I am getting below error.
Bad request : {'explanation': 'The server could not comply with the request since it is either malformed or otherwise incorrect.', 'code': 400, 'error': {'message': 'Property error: : resources.VM1.properties.template: : No content found in the "files" section for get_file path: C:/Users/xxx/PycharmProjects/xxx/vm/VM1.yaml', 'traceback': None, 'type': 'StackValidationFailed'}, 'title': 'Bad Request'
I dont understand what I need to do.
Solved it using files, template = template_utils.process_template_path(template_file)