summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2012-02-10 15:19:49 -0500
committerVishvananda Ishaya <vishvananda@gmail.com>2012-03-02 15:02:00 -0800
commit4a2cf658dca26965cb06f478ad030ecda4d7fc43 (patch)
tree199db1fe96595f057387dd6fe71b0aa965087624 /nova/api
parentf0a172ea8bcd5b241115210fcdbe33cf268ef051 (diff)
downloadnova-4a2cf658dca26965cb06f478ad030ecda4d7fc43.tar.gz
nova-4a2cf658dca26965cb06f478ad030ecda4d7fc43.tar.xz
nova-4a2cf658dca26965cb06f478ad030ecda4d7fc43.zip
populate glance 'name' field through ec2-register
For images registered via RegisterImage in the ec2 api, populate glance's 'name' field. If the name is not supplied in the ec2 request, then set it to be the location. This has the added value of 'glance index' now showing ec2 registered images. Previously, they were not listed because of the empty Name field. Additionally, when responding to DescribeImages in the ec2 api, populate the name field. Previously we were not populating this at all. In the case where there is no name, use image_location. Fixes bug 930314 Change-Id: I10bcac9ab298a2bf127b5228c62c3cf4f009abd6
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/ec2/cloud.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py
index 5240af016..a5e491b18 100644
--- a/nova/api/ec2/cloud.py
+++ b/nova/api/ec2/cloud.py
@@ -1365,11 +1365,18 @@ class CloudController(object):
if ramdisk_id:
i['ramdiskId'] = ec2utils.image_ec2_id(ramdisk_id, 'ari')
i['imageOwnerId'] = image['properties'].get('owner_id')
- if name:
- i['imageLocation'] = "%s (%s)" % (image['properties'].
- get('image_location'), name)
+
+ img_loc = image['properties'].get('image_location')
+ if img_loc:
+ i['imageLocation'] = img_loc
else:
- i['imageLocation'] = image['properties'].get('image_location')
+ i['imageLocation'] = "%s (%s)" % (img_loc, name)
+
+ i['name'] = name
+ if not name and img_loc:
+ # This should only occur for images registered with ec2 api
+ # prior to that api populating the glance name
+ i['name'] = img_loc
i['imageState'] = self._get_image_state(image)
i['description'] = image.get('description')
@@ -1425,10 +1432,15 @@ class CloudController(object):
return image_id
def register_image(self, context, image_location=None, **kwargs):
- if image_location is None and 'name' in kwargs:
+ if image_location is None and kwargs.get('name'):
image_location = kwargs['name']
metadata = {'properties': {'image_location': image_location}}
+ if kwargs.get('name'):
+ metadata['name'] = kwargs['name']
+ else:
+ metadata['name'] = image_location
+
if 'root_device_name' in kwargs:
metadata['properties']['root_device_name'] = kwargs.get(
'root_device_name')