diff options
| author | Ewan Mellor <ewan.mellor@citrix.com> | 2010-08-14 11:46:10 +0100 |
|---|---|---|
| committer | Ewan Mellor <ewan.mellor@citrix.com> | 2010-08-14 11:46:10 +0100 |
| commit | b7ffb210f010baa94495fcd4e9a9dca1ddc3ffe4 (patch) | |
| tree | 0f797c2589b76e627321da82de243bf86599269c | |
| parent | 2bbb2b86272c89b35a1042ab2866bbe4863bc3e3 (diff) | |
| download | nova-b7ffb210f010baa94495fcd4e9a9dca1ddc3ffe4.tar.gz nova-b7ffb210f010baa94495fcd4e9a9dca1ddc3ffe4.tar.xz nova-b7ffb210f010baa94495fcd4e9a9dca1ddc3ffe4.zip | |
Bug #617776: DescribeImagesResponse contains type element, when it should be called imageType
Make the objectstore respond with the field 'imageType' as well as 'type'.
The former is the correct one, according to the EC2 API specification for
the DescribeImages response. The latter is for compatibility with euca2ools
and other clients.
| -rw-r--r-- | nova/objectstore/handler.py | 18 | ||||
| -rw-r--r-- | nova/objectstore/image.py | 4 |
2 files changed, 19 insertions, 3 deletions
diff --git a/nova/objectstore/handler.py b/nova/objectstore/handler.py index f625a2aa1..dfe1918e3 100644 --- a/nova/objectstore/handler.py +++ b/nova/objectstore/handler.py @@ -269,7 +269,23 @@ class ImagesResource(Resource): images = [i for i in image.Image.all() \ if i.is_authorized(request.context, readonly=True)] - request.write(json.dumps([i.metadata for i in images])) + # Bug #617776: + # We used to have 'type' in the image metadata, but this field + # should be called 'imageType', as per the EC2 specification. + # For compat with old metadata files we copy type to imageType if + # imageType is not present. + # For compat with euca2ools (and any other clients using the + # incorrect name) we copy imageType to type. + # imageType is primary if we end up with both in the metadata file + # (which should never happen). + def decorate(m): + if 'imageType' not in m and 'type' in m: + m[u'imageType'] = m['type'] + elif 'imageType' in m: + m[u'type'] = m['imageType'] + return m + + request.write(json.dumps([decorate(i.metadata) for i in images])) request.finish() return server.NOT_DONE_YET diff --git a/nova/objectstore/image.py b/nova/objectstore/image.py index 860298ba6..861eb364f 100644 --- a/nova/objectstore/image.py +++ b/nova/objectstore/image.py @@ -148,7 +148,7 @@ class Image(object): 'imageOwnerId': 'system', 'isPublic': public, 'architecture': 'x86_64', - 'type': image_type, + 'imageType': image_type, 'state': 'available' } @@ -195,7 +195,7 @@ class Image(object): 'imageOwnerId': context.project.id, 'isPublic': False, # FIXME: grab public from manifest 'architecture': 'x86_64', # FIXME: grab architecture from manifest - 'type' : image_type + 'imageType' : image_type } def write_state(state): |
