If multiple resources are created in a nested template how do you reference the attributes of those resources.

asked 2014-10-16 15:46:21 -0600

Heather gravatar image

updated 2014-10-16 15:56:41 -0600

I have created a nested template that creates a network and a subnet. From the parent HOT template I can create a resource called Net1 using a nested type of create_net.template. In create_net.template I reference the resources as my_network and my_subnet.

It doesn't seem that I can do a get_resource against my_subnet or any resource created in the child template from the parent HOT doc.

So in order to get the subnet_id of the subnet created I tried to do

{ get_attr: [Net1, subnets, 0] }

that gives an error. My question is how do I get the subnet id of the subnet created in the child template and use it in the parent template?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2015-10-22 16:25:14 -0600

This did not work for me at all.

I have a heat template that I can stack and the output attributes populate appropriately referencing OS::Neutron::Ports and OS::Nova::Server attributes after they are created. Here is a partial list of outputs from the template I want to nest:

heat output-show --all ve_ha_test_3_nic
    "output_value": "ve_ha_test_3_nic-ve_instance-opfcdup6vonr", 
    "description": "Name of the instance", 
    "output_key": "ve_instance_name"
    "output_value": "da494d97-a9c9-4470-8f6c-e89b749403b9", 
    "description": "The mgmt port id of f5 VE instance", 
    "output_key": "mgmt_port"
    "output_value": "", 
    "description": "The mgmt IP address of f5 ve instance", 
    "output_key": "mgmt_ip"

So you can see I get values for output keys:


When I try to launch the same template as a nested template and try to access the way you suggested

heat_template_version: 2014-10-16
    type: https://.../ve_cluster_member_3_nic.yaml
      ve_image: 6f4ae76b-7a9d-4417-9fdb-397af130067f 
      ve_flavor: 9d416522-7eaa-420a-abc7-17b2c578d5af 
      use_config_drive: True 
      ssh_key: stack_key 
      admin_password: openstack 
      root_password: openstack 
      http_proxy_host: None 
      http_proxy_port: 8080 
      http_proxy_script_url: https://.../license_http_proxy
      license_activation_host: None 
      license_activation_port: 443 
      mgmt_network: 1c20a693-3fdc-4fc7-b9ea-19dbcd6c6e6b 
      ha_network: 5cec0196-00e2-4347-b510-045225f6e720 
      default_gateway: None 
      network_1: 9bbfc10f-8374-4d83-b360-eee96ca89eac 
      network_1_name: TRUSTED
      license: 12345678890
    value: { get_attr: f5_ve_instance_1, ve_instance_name }
    value: { get_attr: f5_ve_instance_1, mgmt_ip }
    value: { get_attr: f5_ve_instance_1, mgmt_port }

What I get when I query the top level template for the outputs defined which point to referenced output of the nested template, I don't get values I get 'null' for everything.

heat output-show --all f5_ve_ha_1_0_1
    "output_value": {
      "get_attr": "f5_ve_instance_1", 
      "ve_instance_name": null
    "description": "No description given", 
    "output_key": "f5_ve_instance_name_1"
    "output_value": {
      "get_attr": "f5_ve_instance_1", 
      "mgmt_ip": null
    "description": "No description given", 
    "output_key": "f5_ve_mgmt_ip_1"
    "output_value": {
      "get_attr": "f5_ve_instance_1", 
      "mgmt_port": null
    "description": "No description given", 
    "output_key": "f5_ve_mgmt_port_1"

Maybe the top level template is looking for those attributes before the nested template can populate them? How do I specify that my template 'wait' for a value?


edit flag offensive delete link more

answered 2014-10-16 18:17:22 -0600

asalkeld gravatar image


Yeah, you can't do that yet. The way get it is to add an outputs section to your nested stack. As an example: https://github.com/openstack/heat-tem... to reference the network in that nested stack {get_attr: [my_vm, instance_networks]}


edit flag offensive delete link more

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2014-10-16 15:46:21 -0600

Seen: 3,034 times

Last updated: Oct 16 '14