[openstack-dev] [nova][glance] Format of 'locations' data in image metadata ?

Nikhil Komawar nik.komawar at gmail.com
Tue May 19 17:33:19 UTC 2015


Hi Daniel,

It's stored as "JSONEncodedDict" as shown below. This is a DB model and 
can accept arbitrarily large and nested data structure.

Hope this helps.

    class JSONEncodedDict(TypeDecorator):
         """Represents an immutable structure as a json-encoded string"""

         impl = Text

         def process_bind_param(self, value, dialect):
             if value is not None:
                 value = jsonutils.dumps(value)
             return value

         def process_result_value(self, value, dialect):
             if value is not None:
                 value = jsonutils.loads(value)
             return value


Regards,
Nikhil

On 5/19/15 12:19 PM, Daniel P. Berrange wrote:
> In Nova we are attempting to model[1] the glance image metadata and
> properties using the Nova object model (now oslo.versionedobjects).
>
> The one item I'm stuck on understanding is the 'locations' field
> and more specifically the 'metadata' element in each location
> entry
>
>
> In the file glance/api/v2/images.py I can see this description
> of the data format:
>
>          'locations': {
>              'type': 'array',
>              'items': {
>                  'type': 'object',
>                  'properties': {
>                      'url': {
>                          'type': 'string',
>                          'maxLength': 255,
>                      },
>                      'metadata': {
>                          'type': 'object',
>                      },
>                  },
>                  'required': ['url', 'metadata'],
>              },
>              'description': _('A set of URLs to access the image file kept in '
>                               'external store'),
>
>
> As you can see here, 'metadata' is just said to be of type 'object'.
>
> Is there somewhere that actually describes what is valid contents
> for this field ? Is it sufficient to assume the metadata will only
> ever be a dict of strings, or can the metadata be a complex type
> with arbitrarily nested data structures ?
>
> Regards,
> Daniel
>
> [1] https://review.openstack.org/#/c/76234/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20150519/3a64a011/attachment.html>


More information about the OpenStack-dev mailing list