Using intrinsic function get_attr in hot template

Asked by Nilanjan Roy

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.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 283, in _add_dependencies
    value, att = value

ValueError: too many values to unpack
------------------------------------------------
If I remove the get_attr part from the template my stack is getting created. Can anyone help me regarding this?

Question information

Language:
English Edit question
Status:
Answered
For:
OpenStack Heat Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Steve Baker (steve-stevebaker) said :
#1

https://answers.launchpad.net/heat is now disabled for questions. (I'm not sure how you managed to ask ;)

Could you please re-ask this at ask.openstack.org? Please tag the question with 'heat'

But here is a sneaky answer, get_attr with multiple arguments was only added in the git master of Heat.

Can you help with this problem?

Provide an answer of your own, or ask Nilanjan Roy for more information if necessary.

To post a message you must log in.