Ask Your Question
0

Using intrinsic function get_attr in hot template

asked 2014-03-05 04:29:51 -0500

Nilanjan-Roy gravatar image

updated 2014-08-13 11:48:34 -0500

zaneb gravatar image

Hi,

I am trying to create a heat stack with three VMs. I am using get_attr to get some attribute. Below is the excerpt of my template

heat_template_version: 2013-05-23
description: >
  Heat template
parameters:
  key_name:
    type: string
    description : Name of a KeyPair to enable SSH access to the instance
    default: CtrlKey
  instance_type:
    type: string
    description: Instance type for NECC instance
    default: m1.small
    constraints:
      - allowed_values: [m1.small, m1.medium, m1.large]
        description: instance_type must be one of m1.small, m1.medium or m1.large
  image_id:
    type: string
    description: ID of the image to use for the WordPress server
    default: test
    constraints:
      - allowed_values: [ test, test1]
        description: >
          Image ID must be either test or test1
  network_id:
    type: string
    description: ID of the network
    default: 0160deac-bfef-4974-ae1c-a458e22a9ee2
  subnet_id:
    type: string
    description: ID of the subnet
    default: d0cd8dc3-a3a2-4853-afc7-f9d2f986e371
  file_name:
    type: string
    description : Name of a test file
    default: /root/install_file
resources:
 serv_port:
    type: OS::Neutron::Port
    properties:
      fixed_ips:
        - ip_address: 172.31.31.100
      network_id: {get_param: network_id}
 webserv:
    type: OS::Nova::Server
    properties:
      image: { get_param: image_id }
      flavor: { get_param: instance_type }
      key_name: { get_param: key_name }
      networks:
        - port: {get_resource: serv_port}
      user_data:
        str_replace:
          template: |
            #!/bin/bash -v
            echo "Installing" > file
            echo $IP >> file
          params:
            file: { get_param: file_name }
            $IP: { get_attr: [serv_port, fixed_ips, 0, ip_address] }

When I am creating the stack I am getting a long traceback ...

Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/heat/openstack/common/rpc/amqp.py", line 461, in _process_data
    **args)
  File "/usr/lib/python2.6/site-packages/heat/openstack/common/rpc/dispatcher.py", line 172, in dispatch
    result = getattr(proxyobj, method)(ctxt, **kwargs)
  File "/usr/lib/python2.6/site-packages/heat/engine/service.py", line 60, in wrapped
    return func(self, ctx, *args, **kwargs)
  File "/usr/lib/python2.6/site-packages/heat/engine/service.py", line 279, in create_stack
    self._validate_deferred_auth_context(cnxt, stack)
  File "/usr/lib/python2.6/site-packages/heat/engine/service.py", line 225, in _validate_deferred_auth_context
    if not stack.requires_deferred_auth():
  File "/usr/lib/python2.6/site-packages/heat/engine/parser.py", line 324, in requires_deferred_auth
    return any(res.requires_deferred_auth for res in self)
  File "/usr/lib/python2.6/site-packages/heat/engine/parser.py", line 243, in __iter__
    return iter(self.dependencies)
  File "/usr/lib/python2.6/site-packages/heat/engine/parser.py", line 122, in dependencies
    self.resources.itervalues())
  File "/usr/lib/python2.6/site-packages/heat/engine/parser.py", line 167, in _get_dependencies
    resource.add_dependencies(deps)
  File "/usr/lib/python2.6/site-packages/heat/engine/resource.py", line 300, in add_dependencies
    self._add_dependencies(deps, self.name, self.t)
  File "/usr/lib/python2.6/site-packages/heat/engine/resource.py", line 294, in _add_dependencies
    self._add_dependencies(deps, '%s.%s' % (path, key), value)
  File "/usr/lib/python2.6/site-packages/heat/engine/resource.py", line 294, in _add_dependencies
    self._add_dependencies(deps, '%s.%s' % (path, key), value)
  File "/usr/lib/python2.6/site-packages/heat/engine/resource.py", line 294, in _add_dependencies
    self._add_dependencies(deps, '%s.%s' % (path, key), value)
  File "/usr/lib/python2.6/site-packages/heat/engine/resource.py", line 294, in _add_dependencies
    self._add_dependencies(deps, '%s.%s' % (path, key), value)
  File "/usr/lib/python2 ...
(more)
edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
2

answered 2014-06-24 09:44:48 -0500

Ukesh gravatar image

$IP: { get_attr: [serv_port, fixed_ips, 0, ip_address] }

above will work from icehouse release only. For havana, try below,

$IP: {"Fn::Select": [ ip_address, "Fn::Select": [ 0, { "Fn::GetAtt": [ serv_port, fixed_ips ]}]]}

edit flag offensive delete link more
0

answered 2014-03-10 12:22:36 -0500

zaneb gravatar image

This feature (allowing more than two arguments to get_attr) will be available in the Icehouse release, and should work in the current master branch, but evidently not in the version of Heat you're using (which may be Havana, or just a non-bleeding-edge version of master).

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

Stats

Asked: 2014-03-05 04:29:51 -0500

Seen: 1,533 times

Last updated: Aug 13 '14