summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorSandy Walsh <sandy.walsh@rackspace.com>2011-01-17 16:47:19 -0800
committerSandy Walsh <sandy.walsh@rackspace.com>2011-01-17 16:47:19 -0800
commit5ff189808d45582f0799c14eaaec687a3cf8ad5e (patch)
tree09dead24b018e80ba9178c3ddf72e9360d88f8b1 /nova/api
parentf28b7aa6fc51fcbae3c82b88f6e946124b1f2a98 (diff)
openstack api fixes for glance
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/common.py7
-rw-r--r--nova/api/openstack/servers.py1
2 files changed, 7 insertions, 1 deletions
diff --git a/nova/api/openstack/common.py b/nova/api/openstack/common.py
index 037ed47a0..3b93d961e 100644
--- a/nova/api/openstack/common.py
+++ b/nova/api/openstack/common.py
@@ -38,6 +38,11 @@ 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.
@@ -54,7 +59,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 = get_image_id_or_id(image)
if abs(hash(image_id)) == int(image_hash):
return image_id
raise exception.NotFound(image_hash)
diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py
index 8cbcebed2..54af09a5d 100644
--- a/nova/api/openstack/servers.py
+++ b/nova/api/openstack/servers.py
@@ -127,6 +127,7 @@ class Controller(wsgi.Controller):
def _get_kernel_ramdisk_from_image(self, image_id):
mapping_filename = FLAGS.os_krm_mapping_file
+ image_id = str(image_id)
with open(mapping_filename) as f:
mapping = json.load(f)
if image_id in mapping: