Fix loggin in creation server in OpenStack API 1.0
This commit is contained in:
commit
52b675da69
@ -25,7 +25,7 @@ from nova import log as logging
|
||||
from nova import wsgi
|
||||
|
||||
|
||||
LOG = logging.getLogger('common')
|
||||
LOG = logging.getLogger('nova.api.openstack.common')
|
||||
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
@ -116,8 +116,14 @@ def get_image_id_from_image_hash(image_service, context, image_hash):
|
||||
items = image_service.index(context)
|
||||
for image in items:
|
||||
image_id = image['id']
|
||||
if abs(hash(image_id)) == int(image_hash):
|
||||
return 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.NotFound(image_hash)
|
||||
|
||||
|
||||
|
@ -129,8 +129,13 @@ class Controller(common.OpenstackController):
|
||||
key_data = key_pair['public_key']
|
||||
|
||||
requested_image_id = self._image_id_from_req_data(env)
|
||||
image_id = common.get_image_id_from_image_hash(self._image_service,
|
||||
context, requested_image_id)
|
||||
try:
|
||||
image_id = common.get_image_id_from_image_hash(self._image_service,
|
||||
context, requested_image_id)
|
||||
except:
|
||||
msg = _("Can not find requested image")
|
||||
return faults.Fault(exc.HTTPBadRequest(msg))
|
||||
|
||||
kernel_id, ramdisk_id = self._get_kernel_ramdisk_from_image(
|
||||
req, image_id)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user