[Openstack] [Heat] Specifying metadata in Properties section is not mapped correctly
Zane Bitter
zbitter at redhat.com
Wed Nov 20 11:00:35 UTC 2013
On 20/11/13 11:31, Daniel Kuffner wrote:
> Hi All,
> I currently try to extend the docker driver. The final result should
> be that a user can specify a host folder which should be mounted into
> the docker container.
>
> for testing I have specified some custom metadata in heat like:
>
> HeatTemplateFormatVersion: '2012-12-12'
> Parameters: {}
> Mappings: {}
> Resources:
> busybox:
> Type: OS::Nova::Server
> Properties:
> flavor: m1.small
> image: busybox:latest
> metadata:
> Volumes: "/tmp:/tmp/"
>
> When I try to read the metadata in the docker driver
> (/usr/lib/python2.6/site-packages/nova/virt/docker/driver.py) from the
> given instance object then I get something like:
>
> instance['metadata']
>
> [{
> u'instance_uuid': u'7bc909c4-76d4-42d3-812d-310095f28757',
> u'deleted': 0,
> u'created_at': u'2013-11-20T10:16:14.000000',
> u'updated_at': None,
> u'value': u'/tmp:/tmp',
> u'key': u'Volumes',
> u'deleted_at': None,
> u'id': 56
> }]
>
> Please note that the map does not container "Volumes: /tmp:/tmp" but a
> "value" and a "key" key.
> To access the needed value I have to:
>
> instance['metadata'][0]['value']
>
> instead of:
>
> instance['metadata'][0]['Volumes']
>
> Is that a bug in heat or is my template wrong?
> does anybody else use the metadata section in a heat template?
Heat is just passing a dictionary to Nova, so it seems like that's just
how Nova supplies the metadata to plugins? You should be able to easily
turn it back in to the format you want if you are happy to throw away
the rest of that data:
metadata = dict((m['key'], m['value']) for m in instance['metadata'])
cheers,
Zane.
More information about the Openstack
mailing list