summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorNaveed Massjouni <naveedm9@gmail.com>2011-05-20 04:14:02 -0400
committerNaveed Massjouni <naveedm9@gmail.com>2011-05-20 04:14:02 -0400
commite16b2d22dc4e6e24c3bf5150a0830661933aad29 (patch)
treef2ccb5b54289c237dc4a15ddb247782f26941b93 /nova/api
parenta1869741689817168c75046f2f81ee9761956cbc (diff)
Fixed some tests.
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/common.py28
-rw-r--r--nova/api/openstack/servers.py6
2 files changed, 3 insertions, 31 deletions
diff --git a/nova/api/openstack/common.py b/nova/api/openstack/common.py
index 32cd689ca..a89594c13 100644
--- a/nova/api/openstack/common.py
+++ b/nova/api/openstack/common.py
@@ -100,34 +100,6 @@ def limited_by_marker(items, request, max_limit=FLAGS.osapi_max_limit):
return items[start_index:range_end]
-def get_image_id_from_image_hash(image_service, context, image_hash):
- """Given an Image ID Hash, return an objectstore Image ID.
-
- image_service - reference to objectstore compatible image service.
- context - security context for image service requests.
- image_hash - hash of the image ID.
- """
-
- # FIX(sandy): This is terribly inefficient. It pulls all images
- # from objectstore in order to find the match. ObjectStore
- # should have a numeric counterpart to the string ID.
- try:
- items = image_service.detail(context)
- except NotImplementedError:
- items = image_service.index(context)
- for image in items:
- image_id = image['id']
- try:
- if abs(hash(image_id)) == int(image_hash):
- return image_id
- except ValueError:
- msg = _("Requested image_id has wrong format: %s,"
- "should have numerical format") % image_id
- LOG.error(msg)
- raise Exception(msg)
- raise exception.ImageNotFound(image_id=image_hash)
-
-
def get_id_from_href(href):
"""Return the id portion of a url as an int.
diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py
index 337c6ced8..31c1e86c0 100644
--- a/nova/api/openstack/servers.py
+++ b/nova/api/openstack/servers.py
@@ -144,10 +144,10 @@ class Controller(common.OpenstackController):
(image_service, image_id) = utils.get_image_service(image_ref)
kernel_id, ramdisk_id = self._get_kernel_ramdisk_from_image(
req, image_id)
- image_set = set([x['id'] for x in image_service.index(context)])
- assert image_id in image_set
+ images = set([str(x['id']) for x in image_service.index(context)])
+ assert str(image_id) in images
except:
- msg = _("Can not find requested image")
+ msg = _("Cannot find requested image %s") % image_ref
return faults.Fault(exc.HTTPBadRequest(msg))
personality = env['server'].get('personality')