From 0d78045e72efe7313ca54e726dd403793eb30b52 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Thu, 1 Mar 2012 16:52:07 -0800 Subject: Fixes for ec2 images * Fixes s3 image service to convert back to uuids on update * Adds exception for attempt to update an unowned image * Adds error messages to ec2 for failure cases * Adds tests to verify changes * Fixes bug 942865 Change-Id: I35331c635756f10c02b30dd43ab3fe0ad98bc28c --- nova/api/ec2/cloud.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'nova/api') diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 5240af016..b27f79c62 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -1427,6 +1427,9 @@ class CloudController(object): def register_image(self, context, image_location=None, **kwargs): if image_location is None and 'name' in kwargs: image_location = kwargs['name'] + if image_location is None: + raise exception.EC2APIError(_('imageLocation is required')) + metadata = {'properties': {'image_location': image_location}} if 'root_device_name' in kwargs: @@ -1501,7 +1504,11 @@ class CloudController(object): del(image['id']) image['is_public'] = (operation_type == 'add') - return self.image_service.update(context, internal_id, image) + try: + return self.image_service.update(context, internal_id, image) + except exception.ImageNotAuthorized: + msg = _('Not allowed to modify attributes for image %s') + raise exception.EC2APIError(msg % image_id) def update_image(self, context, image_id, **kwargs): internal_id = ec2utils.ec2_id_to_id(image_id) -- cgit