summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nova/objectstore/handler.py18
-rw-r--r--nova/objectstore/image.py4
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):