Merge lp:~reldan/nova/lp764551 into lp:~hudson-openstack/nova/trunk

Proposed by Eldar Nugaev
Status: Merged
Approved by: Devin Carlen
Approved revision: 1000
Merged at revision: 999
Proposed branch: lp:~reldan/nova/lp764551
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 48 lines (+16/-5)
2 files modified
nova/api/openstack/common.py (+9/-3)
nova/api/openstack/servers.py (+7/-2)
To merge this branch: bzr merge lp:~reldan/nova/lp764551
Reviewer Review Type Date Requested Status
Devin Carlen (community) Approve
Rick Harris (community) Approve
Jay Pipes (community) Approve
Review via email: mp+58115@code.launchpad.net

Description of the change

Fix loggin in creation server in OpenStack API 1.0

To post a comment you must log in.
lp:~reldan/nova/lp764551 updated
997. By Eldar Nugaev

Fix logging in openstack api

998. By Eldar Nugaev

Fix logging in openstack api

999. By Eldar Nugaev

add fault as response

1000. By Eldar Nugaev

pep8 fix

Revision history for this message
Jay Pipes (jaypipes) wrote :

good stuff, thanks Eldar!

review: Approve
Revision history for this message
Rick Harris (rconradharris) wrote :

lgtm

review: Approve
Revision history for this message
Eldar Nugaev (reldan) wrote :

Thank you!

Revision history for this message
Devin Carlen (devcamcar) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/api/openstack/common.py'
2--- nova/api/openstack/common.py 2011-03-30 17:05:06 +0000
3+++ nova/api/openstack/common.py 2011-04-18 15:37:49 +0000
4@@ -25,7 +25,7 @@
5 from nova import wsgi
6
7
8-LOG = logging.getLogger('common')
9+LOG = logging.getLogger('nova.api.openstack.common')
10
11
12 FLAGS = flags.FLAGS
13@@ -116,8 +116,14 @@
14 items = image_service.index(context)
15 for image in items:
16 image_id = image['id']
17- if abs(hash(image_id)) == int(image_hash):
18- return image_id
19+ try:
20+ if abs(hash(image_id)) == int(image_hash):
21+ return image_id
22+ except ValueError:
23+ msg = _("Requested image_id has wrong format: %s,"
24+ "should have numerical format") % image_id
25+ LOG.error(msg)
26+ raise Exception(msg)
27 raise exception.NotFound(image_hash)
28
29
30
31=== modified file 'nova/api/openstack/servers.py'
32--- nova/api/openstack/servers.py 2011-04-08 00:32:34 +0000
33+++ nova/api/openstack/servers.py 2011-04-18 15:37:49 +0000
34@@ -127,8 +127,13 @@
35 key_data = key_pair['public_key']
36
37 requested_image_id = self._image_id_from_req_data(env)
38- image_id = common.get_image_id_from_image_hash(self._image_service,
39- context, requested_image_id)
40+ try:
41+ image_id = common.get_image_id_from_image_hash(self._image_service,
42+ context, requested_image_id)
43+ except:
44+ msg = _("Can not find requested image")
45+ return faults.Fault(exc.HTTPBadRequest(msg))
46+
47 kernel_id, ramdisk_id = self._get_kernel_ramdisk_from_image(
48 req, image_id)
49