Ask Your Question
0

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

asked 2018-06-17 11:36:01 -0500

ansreas gravatar image

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.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-06-25 10:36:18 -0500

zaneb gravatar image

updated 2018-06-25 10:36:51 -0500

It is possible to nest get_attr and get_param functions.

However, the first argument to get_attr is the name of a resource in the current stack. If you pass something else, like the name of a resource in a different stack (as in your example), it won't work.

The correct way to do what you want here is to pass the network and subnet UUIDs as parameters to my_routerport.yaml.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2018-06-17 11:36:01 -0500

Seen: 166 times

Last updated: Jun 25 '18