diff options
| author | Jenkins <jenkins@review.openstack.org> | 2011-11-11 18:42:39 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2011-11-11 18:42:39 +0000 |
| commit | ed3635f40fa31b896bb700610b93fe288a90e692 (patch) | |
| tree | d0406a2ade46b979515a02711a4b22a8c7329655 | |
| parent | fb6a2d15be16f664b2159526fa339019ed4c204a (diff) | |
| parent | 231f40af80c69f80aec4922f1261f4fdf5365a3c (diff) | |
| download | nova-ed3635f40fa31b896bb700610b93fe288a90e692.tar.gz nova-ed3635f40fa31b896bb700610b93fe288a90e692.tar.xz nova-ed3635f40fa31b896bb700610b93fe288a90e692.zip | |
Merge "Converting set password to use instance objects"
| -rw-r--r-- | nova/api/openstack/servers.py | 3 | ||||
| -rw-r--r-- | nova/compute/api.py | 5 | ||||
| -rw-r--r-- | nova/tests/api/openstack/test_server_actions.py | 4 | ||||
| -rw-r--r-- | nova/tests/test_compute.py | 2 |
4 files changed, 9 insertions, 5 deletions
diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 539fd8778..b913a2bb5 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -744,7 +744,8 @@ class Controller(object): if not isinstance(password, basestring) or password == '': msg = _("Invalid adminPass") raise exc.HTTPBadRequest(explanation=msg) - self.compute_api.set_admin_password(context, id, password) + server = self._get_server(context, id) + self.compute_api.set_admin_password(context, server, password) return webob.Response(status_int=202) def _limit_items(self, items, req): diff --git a/nova/compute/api.py b/nova/compute/api.py index 2b0db25f4..6549031e2 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -1430,8 +1430,11 @@ class API(base.Base): self._cast_compute_message('unrescue_instance', context, instance_id) @scheduler_api.reroute_compute("set_admin_password") - def set_admin_password(self, context, instance_id, password=None): + def set_admin_password(self, context, instance, password=None): """Set the root/admin password for the given instance.""" + #NOTE(bcwaldon): we need to use the integer id here since manager uses + # db.instance_get, not db.instance_get_by_uuid + instance_id = instance['id'] self.update(context, instance_id, task_state=task_states.UPDATING_PASSWORD) diff --git a/nova/tests/api/openstack/test_server_actions.py b/nova/tests/api/openstack/test_server_actions.py index df0bfd968..9d50483b8 100644 --- a/nova/tests/api/openstack/test_server_actions.py +++ b/nova/tests/api/openstack/test_server_actions.py @@ -122,8 +122,8 @@ class MockSetAdminPassword(object): self.instance_id = None self.password = None - def __call__(self, context, instance_id, password): - self.instance_id = instance_id + def __call__(self, context, instance, password): + self.instance_id = instance['uuid'] self.password = password diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index 9cf580b1f..20a8e3d5b 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -1182,7 +1182,7 @@ class ComputeAPITestCase(BaseTestCase): self.assertEqual(inst_ref['vm_state'], vm_states.ACTIVE) self.assertEqual(inst_ref['task_state'], None) - self.compute_api.set_admin_password(self.context, instance_id) + self.compute_api.set_admin_password(self.context, inst_ref) inst_ref = db.instance_get(self.context, instance_id) self.assertEqual(inst_ref['vm_state'], vm_states.ACTIVE) |
