Ask Your Question
0

Unable to access attributes of nested resources in heat

asked 2017-01-10 03:54:37 -0500

rkayyar gravatar image

I have the following templates (skipping obvious details):

Included template (LIB::Dbport)

   resources:
              dbport:
                type: OS::Neutron::Port
                properties:
                  network: { get_param: my_network }
                  fixed_ips:
                    - subnet_id: {get_param: my_subnet}
                  security_groups:
                    - { get_resource: security_group }
   outputs:
       dbportip:
          description: The IP addess of db
          value: { get_attr: [dbport,fixed_ips,0,ip_address] }
      dbport:
        description: The network port of db
        value: { get_resource: dbport }

If I launch only this as a stack, I get the IP address. Now In include this in a 'main' template and try to create a resource group: Main template which includes the above:

resources:

  dbport_cluster:
    type: OS::Heat::ResourceGroup
    properties:
      count: { get_param: cluster_size }
      resource_def:
        type: LIB::Dbport
        properties:
          my_network: { get_param: my_network }

outputs:
  db_ports:
    description: Ports of DB server instances
    value: {get_attr: [dbport_cluster,dbport] }
  db_ips:
    description: IP addreses of DB server instances
    value: {get_attr: [dbport_cluster,dbport, fixed_ips,0,ip_address] }

Now when I create the stack with count(cluster_size)=2, I do get two instance of DB ports created, but the output db_ips shows null. I do see valid ports for db_ports and I am able to do "show port" for both of them and I see good IP addresses. My question: Why don't I get valid IP addresses for the output "db_ips"? What can I do to get IP addresses?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-01-10 16:57:48 -0500

zaneb gravatar image

I think you're thinking that get_resource returns the resource itself, from which you can then get attributes. This is not correct: get_resource returns the UUID of the port. That's why db_ports gives the output it does.

You've actually already defined an output for the IP address, so in the parent template you just have to use it:

db_ips:
  description: IP addreses of DB server instances
  value: {get_attr: [dbport_cluster, dbportip]}
edit flag offensive delete link more

Comments

Thanks, Zaneb. Got it working with the change you suggested.

rkayyar gravatar imagerkayyar ( 2017-01-10 23:18:56 -0500 )edit

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: 2017-01-10 03:54:37 -0500

Seen: 49 times

Last updated: Jan 10