Merge lp:~rackspace-titan/nova/openstack-api-password-gen into lp:~hudson-openstack/nova/trunk

Proposed by Dan Prince
Status: Merged
Approved by: Devin Carlen
Approved revision: 765
Merged at revision: 774
Proposed branch: lp:~rackspace-titan/nova/openstack-api-password-gen
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 71 lines (+19/-5)
3 files modified
nova/api/openstack/servers.py (+9/-2)
nova/compute/api.py (+3/-2)
nova/tests/api/openstack/test_servers.py (+7/-1)
To merge this branch: bzr merge lp:~rackspace-titan/nova/openstack-api-password-gen
Reviewer Review Type Date Requested Status
Devin Carlen (community) Approve
Ed Leafe (community) Approve
Jay Pipes (community) Approve
Review via email: mp+52749@code.launchpad.net

This proposal supersedes a proposal from 2011-03-09.

Description of the change

Update the create server call in the Openstack API so that it generates an 'adminPass' and calls set_admin_password in the compute API. This gets us closer to parity with the Cloud Servers v1.0 spec.

To post a comment you must log in.
Revision history for this message
Jay Pipes (jaypipes) wrote : Posted in a previous version of this proposal

Hi Dan!

You state in the commit message above this is for v1.0 parity, but the blueprint says this is for v1.1. Could you clarify? I was going to set the priority on the blueprint but need an answer on this question before I do...

Thanks!
-jay

Revision history for this message
Josh Kearney (jk0) wrote : Posted in a previous version of this proposal

This looks good to me, but I want Ed to have a look before I approve since he worked on the XenAPI password injection.

Revision history for this message
Dan Prince (dan-prince) wrote : Posted in a previous version of this proposal

Hey Jay. Just updated the Blueprint to say 1.0. This feature is in both 1.0 and 1.1.

Revision history for this message
Jay Pipes (jaypipes) wrote : Posted in a previous version of this proposal

OK, thx Dan for the info. Set the blueprint to Medium priority. Code looks good from my end.

review: Approve
Revision history for this message
Ed Leafe (ed-leafe) wrote : Posted in a previous version of this proposal

I'm not sure I'm following the flow correctly. You are generating a password in the API layer, but not passing it to the compute layer (just the server ID)? When it is handled by nova.compute.manager.set_admin_password(), won't that code simply re-generate another password?

review: Needs Information
Revision history for this message
Dan Prince (dan-prince) wrote :

Just talked to Ed and worked out the issue with the missing password parameter in the compute API.

The latest branch code should resolve that issue (Good catch Ed).

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

Yup, looks good. FYI, Dan, for smallish changes like this last one, just set the merge proposal status to Work In Progress while you make the fix, then after pushing the code, just flip the MP status back to Needs Review. This will trigger a re-diffing and a notification to all prior reviewers to re-review. Just an FYI :)

review: Approve
Revision history for this message
Ed Leafe (ed-leafe) wrote :

lgtm

review: Approve
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/servers.py'
2--- nova/api/openstack/servers.py 2011-03-08 22:14:25 +0000
3+++ nova/api/openstack/servers.py 2011-03-09 19:57:47 +0000
4@@ -98,7 +98,7 @@
5 'application/xml': {
6 "attributes": {
7 "server": ["id", "imageId", "name", "flavorId", "hostId",
8- "status", "progress"]}}}
9+ "status", "progress", "adminPass"]}}}
10
11 def __init__(self):
12 self.compute_api = compute.API()
13@@ -178,7 +178,14 @@
14 key_data=key_pair['public_key'],
15 metadata=metadata,
16 onset_files=env.get('onset_files', []))
17- return _translate_keys(instances[0])
18+
19+ server = _translate_keys(instances[0])
20+ password = "%s%s" % (server['server']['name'][:4],
21+ utils.generate_password(12))
22+ server['server']['adminPass'] = password
23+ self.compute_api.set_admin_password(context, server['server']['id'],
24+ password)
25+ return server
26
27 def update(self, req, id):
28 """ Updates the server name or password """
29
30=== modified file 'nova/compute/api.py'
31--- nova/compute/api.py 2011-03-04 17:20:28 +0000
32+++ nova/compute/api.py 2011-03-09 19:57:47 +0000
33@@ -498,9 +498,10 @@
34 """Unrescue the given instance."""
35 self._cast_compute_message('unrescue_instance', context, instance_id)
36
37- def set_admin_password(self, context, instance_id):
38+ def set_admin_password(self, context, instance_id, password=None):
39 """Set the root/admin password for the given instance."""
40- self._cast_compute_message('set_admin_password', context, instance_id)
41+ self._cast_compute_message('set_admin_password', context, instance_id,
42+ password)
43
44 def inject_file(self, context, instance_id):
45 """Write a file to the given instance."""
46
47=== modified file 'nova/tests/api/openstack/test_servers.py'
48--- nova/tests/api/openstack/test_servers.py 2011-03-07 20:26:35 +0000
49+++ nova/tests/api/openstack/test_servers.py 2011-03-09 19:57:47 +0000
50@@ -218,7 +218,7 @@
51
52 def test_create_instance(self):
53 def instance_create(context, inst):
54- return {'id': '1', 'display_name': ''}
55+ return {'id': '1', 'display_name': 'server_test'}
56
57 def server_update(context, id, params):
58 return instance_create(context, id)
59@@ -262,6 +262,12 @@
60
61 res = req.get_response(fakes.wsgi_app())
62
63+ server = json.loads(res.body)['server']
64+ self.assertEqual('serv', server['adminPass'][:4])
65+ self.assertEqual(16, len(server['adminPass']))
66+ self.assertEqual('server_test', server['name'])
67+ self.assertEqual('1', server['id'])
68+
69 self.assertEqual(res.status_int, 200)
70
71 def test_update_no_body(self):