diff options
| author | Sandy Walsh <sandy.walsh@rackspace.com> | 2011-01-26 16:07:16 +0000 |
|---|---|---|
| committer | Tarmac <> | 2011-01-26 16:07:16 +0000 |
| commit | 8d04abda758a6f322b97013142d9875369276259 (patch) | |
| tree | b64198236e389549e5312e47e76553b7527cc762 | |
| parent | 5e4259ce6deb227b778acf23770e35f786c9c3d0 (diff) | |
| parent | f04b58b1eacccf29162d9898e428ae84a62b3d9c (diff) | |
Simple little changes related to openstack api to work better with glance.
Fixes ImageID missing from Glance and int->string id problem.
| -rw-r--r-- | nova/api/openstack/common.py | 2 | ||||
| -rw-r--r-- | nova/image/s3.py | 11 |
2 files changed, 11 insertions, 2 deletions
diff --git a/nova/api/openstack/common.py b/nova/api/openstack/common.py index 037ed47a0..6d2fa16e8 100644 --- a/nova/api/openstack/common.py +++ b/nova/api/openstack/common.py @@ -54,7 +54,7 @@ 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 = image['imageId'] + image_id = image['id'] 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""" |
