summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEldar Nugaev <enugaev@griddynamics.com>2011-04-18 23:36:04 +0000
committerTarmac <>2011-04-18 23:36:04 +0000
commit52b675da69d573529103e405378c5d3028efa99f (patch)
tree9ce3a16b87c207c21f9b890dfca1efb9290880a2
parent374f79f160c3bf7a7ae9bdfe665a152c75ee9437 (diff)
parentc8ca373cfc71cf62d79ff90957961e9b0aa2ed36 (diff)
Fix loggin in creation server in OpenStack API 1.0
-rw-r--r--nova/api/openstack/common.py12
-rw-r--r--nova/api/openstack/servers.py9
2 files changed, 16 insertions, 5 deletions
diff --git a/nova/api/openstack/common.py b/nova/api/openstack/common.py
index 234f921ab..0b6dc944a 100644
--- a/nova/api/openstack/common.py
+++ b/nova/api/openstack/common.py
@@ -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)
diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py
index 3d39a9cf4..f221229f0 100644
--- a/nova/api/openstack/servers.py
+++ b/nova/api/openstack/servers.py
@@ -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)