Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Is is possible to nest calls of 'get_param' in 'get_attr'?

I want to split a lengthy HEAT template into smaller ones. The example here is stripped down - showing the problem.

env.yaml

resource_registry:
  "My::Subnet": my_subnet.yaml
  "My::RouterPort": my_routerport.yaml

my_subnet.yaml

heat_template_version: 2015-10-15

description: >
  Each network has only one subnet in my environment.
  This function simplifies the setup.

parameters:
  cidr:
    type: string
    description: The network specification
  gateway_ip:
    type: string
    description: The gateway IP address

resources:
  net:
    type: OS::Neutron::Net
  subnet:
    type: OS::Neutron::Subnet
    properties:
      enable_dhcp: false
      network: { get_resource: net }
      cidr: { get_param: cidr }
      gateway_ip: { get_param: gateway_ip }

outputs:
  net:
    value: { get_resource: net }
  subnet:
    value: { get_resource: subnet }

my_routerport.yaml

heat_template_version: 2015-10-15

parameters:
  net:
    type: string
    description: >
      The network where the port is in.
      This must be of type My::Subnet
  ip_address:
    type: string
    description: The IP address of the port
  router:
    type: string
    description: The router the port is attached to

resources:
  port:
    type: OS::Neutron::Port
    properties:
      network: { get_attr: [ { get_param: net }, net ] }
      fixed_ips: [ { subnet: { get_attr: [ { get_param: net }, subnet ] },
                     ip_address: { get_param: ip_address } } ]
  router_interface:
    type: OS::Neutron::RouterInterface
    properties:
      port: { get_resource: port }
      router: { get_param: router }

outputs:
  port:
    value: { get_resource: port }
  router_interface:
    value: { get_resource: router_interface }

main.yaml

heat_template_version: 2015-10-15

resources:
  net_a:
    type: My::Subnet
    properties:
      cidr: 192.164.224.136/29
      gateway_ip: 192.164.124.137
  router_a:
    type: OS::Neutron::Router
  router_interface_1:
    type: My::RouterPort
    properties:
      net: net_a
      ip_address: 192.164.124.137
      router: router_a

Running

heat stack-create --template-file main.yaml -e env.yaml tst001

results in:

ERROR: Failed to validate: : resources.router_interface_1: : The specified reference "net_a" (in port.Properties.fixed_ips[0].subnet) is incorrect.

The question is simple: How to fix this? ;-)

Or (in worst cast): Why does it not work? And maybe a proposal to implement it.