Merge lp:~ken-pepple/nova/lp741965 into lp:~hudson-openstack/nova/trunk

Proposed by Ken Pepple
Status: Merged
Approved by: Jay Pipes
Approved revision: 908
Merged at revision: 935
Proposed branch: lp:~ken-pepple/nova/lp741965
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 68 lines (+14/-12)
2 files modified
nova/api/openstack/views/servers.py (+11/-11)
nova/tests/api/openstack/test_servers.py (+3/-1)
To merge this branch: bzr merge lp:~ken-pepple/nova/lp741965
Reviewer Review Type Date Requested Status
Jay Pipes (community) Approve
Josh Kearney (community) Approve
Review via email: mp+56188@code.launchpad.net

Description of the change

fixes incorrect case of OpenStack API status response

To post a comment you must log in.
Revision history for this message
Naveed Massjouni (ironcamel) wrote :

In servers._build_detail(), why not upper case the values of the power_mapping dict.

And line 14 could be:
    inst_dict['status'] = 'RESIZE-CONFIRM'

Revision history for this message
Josh Kearney (jk0) wrote :

I'd have to agree with Naveed on this -- once that is changed, it will be good to go.

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

test case? this is a perfect example of a bug that will happily re-appear if a test case is not added for it :)

review: Needs Fixing
Revision history for this message
Ken Pepple (ken-pepple) wrote :

so the thought process here was that by upcase-ing it at time of return it would catch any problems when people added powerstates later ... however, I've changed it to just making them capitals.

as to the tests, i caught the resize one, but thought we were just faking the others in wsgi_app(). fixed.

Revision history for this message
Josh Kearney (jk0) wrote :

Thanks Ken, looks great!

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

sweet. thx Ken!

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/views/servers.py'
2--- nova/api/openstack/views/servers.py 2011-03-24 14:15:50 +0000
3+++ nova/api/openstack/views/servers.py 2011-04-04 16:46:30 +0000
4@@ -57,16 +57,16 @@
5 def _build_detail(self, inst):
6 """Returns a detailed model of a server."""
7 power_mapping = {
8- None: 'build',
9- power_state.NOSTATE: 'build',
10- power_state.RUNNING: 'active',
11- power_state.BLOCKED: 'active',
12- power_state.SUSPENDED: 'suspended',
13- power_state.PAUSED: 'paused',
14- power_state.SHUTDOWN: 'active',
15- power_state.SHUTOFF: 'active',
16- power_state.CRASHED: 'error',
17- power_state.FAILED: 'error'}
18+ None: 'BUILD',
19+ power_state.NOSTATE: 'BUILD',
20+ power_state.RUNNING: 'ACTIVE',
21+ power_state.BLOCKED: 'ACTIVE',
22+ power_state.SUSPENDED: 'SUSPENDED',
23+ power_state.PAUSED: 'PAUSED',
24+ power_state.SHUTDOWN: 'ACTIVE',
25+ power_state.SHUTOFF: 'ACTIVE',
26+ power_state.CRASHED: 'ERROR',
27+ power_state.FAILED: 'ERROR'}
28
29 inst_dict = {
30 'id': int(inst['id']),
31@@ -77,7 +77,7 @@
32 ctxt = nova.context.get_admin_context()
33 compute_api = nova.compute.API()
34 if compute_api.has_finished_migration(ctxt, inst['id']):
35- inst_dict['status'] = 'resize-confirm'
36+ inst_dict['status'] = 'RESIZE-CONFIRM'
37
38 # Return the metadata as a dictionary
39 metadata = {}
40
41=== modified file 'nova/tests/api/openstack/test_servers.py'
42--- nova/tests/api/openstack/test_servers.py 2011-03-31 19:45:36 +0000
43+++ nova/tests/api/openstack/test_servers.py 2011-04-04 16:46:30 +0000
44@@ -631,6 +631,7 @@
45 self.assertEqual(s['name'], 'server%d' % i)
46 self.assertEqual(s['imageId'], '10')
47 self.assertEqual(s['flavorId'], '1')
48+ self.assertEqual(s['status'], 'BUILD')
49 self.assertEqual(s['metadata']['seq'], i)
50
51 def test_get_all_server_details_v1_1(self):
52@@ -644,6 +645,7 @@
53 self.assertEqual(s['name'], 'server%d' % i)
54 self.assertEqual(s['imageRef'], 'http://localhost/v1.1/images/10')
55 self.assertEqual(s['flavorRef'], 'http://localhost/v1.1/flavors/1')
56+ self.assertEqual(s['status'], 'BUILD')
57 self.assertEqual(s['metadata']['seq'], i)
58
59 def test_get_all_server_details_with_host(self):
60@@ -917,7 +919,7 @@
61 fake_migration_get)
62 res = req.get_response(fakes.wsgi_app())
63 body = json.loads(res.body)
64- self.assertEqual(body['server']['status'], 'resize-confirm')
65+ self.assertEqual(body['server']['status'], 'RESIZE-CONFIRM')
66
67 def test_confirm_resize_server(self):
68 req = self.webreq('/1/action', 'POST', dict(confirmResize=None))