From 3bf9bc6f6c0fbf90e3f4eab68a9bd99d85fcc422 Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Thu, 6 Jan 2011 21:37:33 -0600 Subject: Reserving image before uploading --- nova/api/openstack/images.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'nova/api') diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py index 867ee5a7e..4d1af77d9 100644 --- a/nova/api/openstack/images.py +++ b/nova/api/openstack/images.py @@ -115,7 +115,8 @@ class Controller(wsgi.Controller): items = self._service.index(req.environ['nova.context']) items = common.limited(items, req) items = [_translate_keys(item) for item in items] - items = [_translate_status(item) for item in items] + #TODO(sirp): removing for glance + #items = [_translate_status(item) for item in items] return dict(images=items) def show(self, req, id): @@ -131,7 +132,12 @@ class Controller(wsgi.Controller): env = self._deserialize(req.body, req) instance_id = env["image"]["serverId"] name = env["image"]["name"] - return compute_api.ComputeAPI().snapshot(context, instance_id, name) + + image_meta = compute_api.ComputeAPI().snapshot( + context, instance_id, name) + + #TODO(sirp): need to map Glance attrs to OpenStackAPI attrs + return dict(image=image_meta) def update(self, req, id): # Users may not modify public images, and that's all that -- cgit From 8de96296dfb22d0e6c491fcaf072210dfbaa67e8 Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Thu, 6 Jan 2011 23:38:01 -0600 Subject: Removing some FIXMEs --- nova/api/openstack/images.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'nova/api') diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py index 4d1af77d9..a826b8435 100644 --- a/nova/api/openstack/images.py +++ b/nova/api/openstack/images.py @@ -76,7 +76,14 @@ def _translate_status(item): 'decrypting': 'preparing', 'untarring': 'saving', 'available': 'active'} - item['status'] = status_mapping[item['status']] + try: + item['status'] = status_mapping[item['status']] + except KeyError: + # TODO(sirp): Performing translation of status (if necessary) here for + # now. Perhaps this should really be done in EC2 API and + # S3ImageService + pass + return item @@ -115,8 +122,7 @@ class Controller(wsgi.Controller): items = self._service.index(req.environ['nova.context']) items = common.limited(items, req) items = [_translate_keys(item) for item in items] - #TODO(sirp): removing for glance - #items = [_translate_status(item) for item in items] + items = [_translate_status(item) for item in items] return dict(images=items) def show(self, req, id): @@ -132,11 +138,10 @@ class Controller(wsgi.Controller): env = self._deserialize(req.body, req) instance_id = env["image"]["serverId"] name = env["image"]["name"] - + image_meta = compute_api.ComputeAPI().snapshot( context, instance_id, name) - #TODO(sirp): need to map Glance attrs to OpenStackAPI attrs return dict(image=image_meta) def update(self, req, id): -- cgit From 69a2612be4e865063fa5982462673f1843e8befc Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Tue, 11 Jan 2011 13:54:23 -0600 Subject: Changes per Edays comments --- nova/api/openstack/images.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nova/api') diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py index 1102098b8..8f3f94ea1 100644 --- a/nova/api/openstack/images.py +++ b/nova/api/openstack/images.py @@ -138,7 +138,7 @@ class Controller(wsgi.Controller): instance_id = env["image"]["serverId"] name = env["image"]["name"] - image_meta = compute_api.ComputeAPI().snapshot( + image_meta = compute.ComputeAPI().snapshot( context, instance_id, name) return dict(image=image_meta) -- cgit From 2c7ffd2dab260c2bfc308ccd0c8d52e57a015413 Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Thu, 13 Jan 2011 13:48:01 -0600 Subject: Fixing Image ID workaround and typo --- nova/api/openstack/images.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'nova/api') diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py index 4415db75f..9d56bc508 100644 --- a/nova/api/openstack/images.py +++ b/nova/api/openstack/images.py @@ -99,9 +99,11 @@ def _filter_keys(item, keys): def _convert_image_id_to_hash(image): - image_id = abs(hash(image['imageId'])) - image['imageId'] = image_id - image['id'] = image_id + if 'imageId' in image: + # Convert EC2-style ID (i-blah) to Rackspace-style (int) + image_id = abs(hash(image['imageId'])) + image['imageId'] = image_id + image['id'] = image_id class Controller(wsgi.Controller): @@ -155,7 +157,7 @@ class Controller(wsgi.Controller): instance_id = env["image"]["serverId"] name = env["image"]["name"] - image_meta = compute.ComputeAPI().snapshot( + image_meta = compute.API().snapshot( context, instance_id, name) return dict(image=image_meta) -- cgit