Provider Resource Attributes forced to string type

Bug #1297938 reported by Steve Lipinski
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
Medium
Tomas Sedovic

Bug Description

Provider Resources seem to be unable to return anything other than strings. Even lists and Maps (JSON) are converted to strings and cannot be passed to other resources as those types.

In Provider resource (template):
...
outputs:
  network_list: [ { network: public } ]

In Provider consumer (template):

provider:
  type: My::Provider
  properties: ...

server:
  type: OS::Nova::Server
  properties:
    networks: { get_attr [ provider, network_list ] }

This leads to the following error in heat-engine.log:
[-] CREATE : Server "server" Stack "test" [1597403e-d0b6-4554-ab3b-6525e0dfab4b]
2014-03-26 12:17:32.239 7092 TRACE heat.engine.resource Traceback (most recent call last):
2014-03-26 12:17:32.239 7092 TRACE heat.engine.resource File "/usr/lib/python2.6/site-packages/heat/engine/resource.py", line 412, in _do_action
2014-03-26 12:17:32.239 7092 TRACE heat.engine.resource pre_func()
2014-03-26 12:17:32.239 7092 TRACE heat.engine.resource File "/usr/lib/python2.6/site-packages/heat/engine/properties.py", line 313, in validate
2014-03-26 12:17:32.239 7092 TRACE heat.engine.resource raise exception.StackValidationFailed(message=msg)
2014-03-26 12:17:32.239 7092 TRACE heat.engine.resource StackValidationFailed: Property error : server: networks "u"[{u'network': u'public'}]"" is not a list

I have also tried this (ouputting a map and wrapping in list when used):
In Provider resource (template):
...
outputs:
  network_obj: { network: public }

In Provider consumer (template):

provider:
  type: My::Provider
  properties: ...

server:
  type: OS::Nova::Server
  properties:
    networks: [ { get_attr [ provider, network_obj ] } ]

This leads to the following error:
2014-03-26 12:22:41.107 7092 ERROR heat.engine.resource [-] CREATE : Server "server" Stack "test" [ef97ee13-d16b-4cfa-a937-9880025e2b50]
2014-03-26 12:22:41.107 7092 TRACE heat.engine.resource Traceback (most recent call last):
2014-03-26 12:22:41.107 7092 TRACE heat.engine.resource File "/usr/lib/python2.6/site-packages/heat/engine/resource.py", line 412, in _do_action
2014-03-26 12:22:41.107 7092 TRACE heat.engine.resource pre_func()
2014-03-26 12:22:41.107 7092 TRACE heat.engine.resource File "/usr/lib/python2.6/site-packages/heat/engine/properties.py", line 313, in validate
2014-03-26 12:22:41.107 7092 TRACE heat.engine.resource raise exception.StackValidationFailed(message=msg)
2014-03-26 12:22:41.107 7092 TRACE heat.engine.resource StackValidationFailed: Property error : server: networks Property error : networks: 0 "{u'network': u'public'}" is not a map

Lastly, I tried to encapsulate the list in a map and returning the map and dereferencing:
In Provider resource (template):
...
outputs:
  network_list_obj: { list: [ { network: public } ] }

In Provider consumer (template):

provider:
  type: My::Provider
  properties: ...

server:
  type: OS::Nova::Server
  properties:
    networks: { get_attr [ provider, network_list_obj, list ] }

This leads to this error (which I don't understand, TBH):
2014-03-26 12:27:23.745 7092 ERROR heat.engine.resource [-] CREATE : Server "server" Stack "test" [fbb4f3f6-5d09-463b-8b81-9b19bacb1277]
2014-03-26 12:27:23.745 7092 TRACE heat.engine.resource Traceback (most recent call last):
2014-03-26 12:27:23.745 7092 TRACE heat.engine.resource File "/usr/lib/python2.6/site-packages/heat/engine/resource.py", line 417, in _do_action
2014-03-26 12:27:23.745 7092 TRACE heat.engine.resource handle())
2014-03-26 12:27:23.745 7092 TRACE heat.engine.resource File "/usr/lib/python2.6/site-packages/heat/engine/resources/server.py", line 519, in handle_create
2014-03-26 12:27:23.745 7092 TRACE heat.engine.resource admin_pass=admin_pass)
2014-03-26 12:27:23.745 7092 TRACE heat.engine.resource File "/usr/lib/python2.6/site-packages/novaclient/v1_1/servers.py", line 658, in create
2014-03-26 12:27:23.745 7092 TRACE heat.engine.resource **boot_kwargs)
2014-03-26 12:27:23.745 7092 TRACE heat.engine.resource File "/usr/lib/python2.6/site-packages/novaclient/base.py", line 402, in _boot
2014-03-26 12:27:23.745 7092 TRACE heat.engine.resource return_raw=return_raw, **kwargs)
2014-03-26 12:27:23.745 7092 TRACE heat.engine.resource File "/usr/lib/python2.6/site-packages/novaclient/base.py", line 145, in _create
2014-03-26 12:27:23.745 7092 TRACE heat.engine.resource _resp, body = self.api.client.post(url, body=body)
2014-03-26 12:27:23.745 7092 TRACE heat.engine.resource File "/usr/lib/python2.6/site-packages/novaclient/client.py", line 232, in post
2014-03-26 12:27:23.745 7092 TRACE heat.engine.resource return self._cs_request(url, 'POST', **kwargs)
2014-03-26 12:27:23.745 7092 TRACE heat.engine.resource File "/usr/lib/python2.6/site-packages/novaclient/client.py", line 213, in _cs_request
2014-03-26 12:27:23.745 7092 TRACE heat.engine.resource **kwargs)
2014-03-26 12:27:23.745 7092 TRACE heat.engine.resource File "/usr/lib/python2.6/site-packages/novaclient/client.py", line 195, in _time_request
2014-03-26 12:27:23.745 7092 TRACE heat.engine.resource resp, body = self.request(url, method, **kwargs)
2014-03-26 12:27:23.745 7092 TRACE heat.engine.resource File "/usr/lib/python2.6/site-packages/novaclient/client.py", line 189, in request
2014-03-26 12:27:23.745 7092 TRACE heat.engine.resource raise exceptions.from_response(resp, body, url, method)
2014-03-26 12:27:23.745 7092 TRACE heat.engine.resource BadRequest: Multiple possible networks found, use a Network ID to be more specific. (HTTP 400) (Request-ID: req-6a7cb07d-a69f-4b48-8cda-5a1d9f862325)

I would expect that any attribute/output should be recognized for a valid type (string, number, json/map, list, etc.)

Changed in heat:
status: New → Triaged
importance: Undecided → Medium
Steven Hardy (shardy)
Changed in heat:
assignee: nobody → Steven Hardy (shardy)
Steven Hardy (shardy)
Changed in heat:
assignee: Steven Hardy (shardy) → nobody
Zane Bitter (zaneb)
Changed in heat:
milestone: none → juno-3
Tomas Sedovic (tsedovic)
Changed in heat:
assignee: nobody → Tomas Sedovic (tsedovic)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to heat (master)

Fix proposed to branch: master
Review: https://review.openstack.org/107621

Changed in heat:
status: Triaged → In Progress
Steven Hardy (shardy)
Changed in heat:
milestone: juno-3 → juno-2
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (master)

Reviewed: https://review.openstack.org/107621
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=83657cf1eb0eb07f14a0186ce6105dc25c783658
Submitter: Jenkins
Branch: master

commit 83657cf1eb0eb07f14a0186ce6105dc25c783658
Author: Tomas Sedovic <email address hidden>
Date: Thu Jul 17 10:15:05 2014 +0200

    Stop coercing provider res. attributes to strings

    Attributes of a resource defined in another template were
    automatically converted to a string. If a provider resource returned
    {"ip": ..., "name": ...} as an attribute value, it was converted to
    "{'ip': ..., 'name': ...}".

    This fix makes the behaviour consistent with the way stack outputs and
    native resource work (i.e. can return strings, lists and maps).

    Closes-Bug: #1297938
    Change-Id: I7f27910e0ec877738998ff80c44e12d3bd4bfa7b

Changed in heat:
status: In Progress → Fix Committed
Changed in heat:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in heat:
milestone: juno-2 → 2014.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.