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.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user