diff --git a/nova/api/openstack/compute/plugins/v3/servers.py b/nova/api/openstack/compute/plugins/v3/servers.py index 6cb7d9e8331f..60cae36954ff 100644 --- a/nova/api/openstack/compute/plugins/v3/servers.py +++ b/nova/api/openstack/compute/plugins/v3/servers.py @@ -1082,10 +1082,7 @@ class ServersController(wsgi.Controller): image_href = self._image_uuid_from_href(image_href) - try: - password = rebuild_dict['admin_pass'] - except (KeyError, TypeError): - password = utils.generate_password() + password = self._get_server_admin_password(rebuild_dict) context = req.environ['nova.context'] instance = self._get_server(context, req, id) diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index 88f872047fe4..6cb2d9f1d858 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -1209,10 +1209,8 @@ class Controller(wsgi.Controller): or 'adminPass' not in body['changePassword']): msg = _("No adminPass was specified") raise exc.HTTPBadRequest(explanation=msg) - password = body['changePassword']['adminPass'] - if not isinstance(password, six.string_types): - msg = _("Invalid adminPass") - raise exc.HTTPBadRequest(explanation=msg) + password = self._get_server_admin_password(body['changePassword']) + server = self._get_server(context, req, id) try: self.compute_api.set_admin_password(context, server, password) @@ -1271,10 +1269,7 @@ class Controller(wsgi.Controller): image_href = self._image_uuid_from_href(image_href) - try: - password = body['adminPass'] - except (KeyError, TypeError): - password = utils.generate_password() + password = self._get_server_admin_password(body) context = req.environ['nova.context'] instance = self._get_server(context, req, id)