Use _get_server_admin_password()

There is _get_server_admin_password() for getting an admin password
in ServersController class. This patch makes some methods use it for
code clean-up.

Change-Id: Iff9d960126e1c09d928d72b572838e6f16cc4f33
This commit is contained in:
Ken'ichi Ohmichi 2013-10-21 10:59:44 +09:00
parent 3fabeb32e1
commit 7d87c4fc64
2 changed files with 4 additions and 12 deletions
nova/api/openstack/compute

@ -1091,10 +1091,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)

@ -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)