templatesnestedopenstack-heat

How is the OpenStack nested template implemented via Openstack API


We want to use the OpenStack API to launch the stack. But the template file will have another template file nested. Is there any way to implement this?

The problematic part in the main template file is as below:

  node_vlan_group:
    type: OS::Heat::ResourceGroup
    depends_on: [node_sp_net]
    properties:
      count: {get_param: node_vlan_count}
      resource_def:
        type: node_vlan_template.yaml
        properties:
          vlan_index: '%index%'
          vlan_names: {get_param: node_vlan_names}
          vlan_cidrs4: {get_param: node_cidrs_ipv4}
          vlan_gateways4: {get_param: node_gateways_ipv4}

In the "type" field, another template is included. But how to use it via API?

(When using the CLI command on heat client, I could put this template and inlined node_vlan_template.yaml at the same folder, it works. but via API, I need a way to provide the content of this node_vlan_template.yaml. )


Solution

  • The issue is resolved by adding the nested file content into the POST body to create the stack. It will look as files: {"node_vlan_template.yaml": "content of node_vlan_template.yaml"}

    Another thing need to be careful is the content should be string dumped from the file, instead python dict object.

    Regarding the ResourceGroup usage, there is a good post on it at http://hardysteven.blogspot.com/2014/09/using-heat-resourcegroup-resources.html