[Openstack] [Heat] Specifying metadata in Properties section is not mapped correctly

Daniel Kuffner daniel.kuffner at gmail.com
Wed Nov 20 12:22:34 UTC 2013


Hi Zane,

I think I misunderstood how the metadata works. I assumes that
instance['metadata'][0] contains all declared metadata values by
key/value (I was already wondering why it is a array at all).

That makes much more sense now.

thank you,
Daniel








On Wed, Nov 20, 2013 at 12:00 PM, Zane Bitter <zbitter at redhat.com> wrote:
> 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.
>
> _______________________________________________
> Mailing list: http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack
> Post to     : openstack at lists.openstack.org
> Unsubscribe : http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack




More information about the Openstack mailing list