diff options
| author | Sandy Walsh <sandy.walsh@rackspace.com> | 2011-01-25 15:06:05 -0600 |
|---|---|---|
| committer | Sandy Walsh <sandy.walsh@rackspace.com> | 2011-01-25 15:06:05 -0600 |
| commit | 0167151518dcfa714ecd8dab55f2378de5edf51f (patch) | |
| tree | 63da3e9dcef0251272b3d34716b03c4d80b9bf67 | |
| parent | a6052241ec7bce94b81e8d4fa1d43353e4eec51b (diff) | |
moved imageId change to s3 client
| -rw-r--r-- | nova/api/openstack/common.py | 8 | ||||
| -rw-r--r-- | nova/image/s3.py | 11 |
2 files changed, 11 insertions, 8 deletions
diff --git a/nova/api/openstack/common.py b/nova/api/openstack/common.py index 3b93d961e..01d620aed 100644 --- a/nova/api/openstack/common.py +++ b/nova/api/openstack/common.py @@ -38,11 +38,6 @@ def limited(items, req): return items[offset:range_end] -def get_image_id_or_id(image): - """Some image services return image_id, others id""" - return image.get('imageId', image.get('id', None)) - - def get_image_id_from_image_hash(image_service, context, image_hash): """Given an Image ID Hash, return an objectstore Image ID. @@ -59,7 +54,6 @@ def get_image_id_from_image_hash(image_service, context, image_hash): except NotImplementedError: items = image_service.index(context) for image in items: - image_id = get_image_id_or_id(image) - if abs(hash(image_id)) == int(image_hash): + if abs(hash(image['id'])) == int(image_hash): return image_id raise exception.NotFound(image_hash) diff --git a/nova/image/s3.py b/nova/image/s3.py index 7b04aa072..62d4d0e63 100644 --- a/nova/image/s3.py +++ b/nova/image/s3.py @@ -65,12 +65,21 @@ class S3ImageService(service.BaseImageService): 'image_id': image_id})) return image_id + def _fix_image_id(images): + """S3 has imageId but OpenStack wants id""" + for image in images: + if 'imageId' in image: + image_id = image['imageId'] + del image['imageId'] + image['id'] = image_id + return images + def index(self, context): """Return a list of all images that a user can see.""" response = self._conn(context).make_request( method='GET', bucket='_images') - return json.loads(response.read()) + return _fix_image_id(json.loads(response.read())) def show(self, context, image_id): """return a image object if the context has permissions""" |
