diff options
| author | Mark Washenberger <mark.washenberger@rackspace.com> | 2011-04-18 22:11:31 +0000 |
|---|---|---|
| committer | Tarmac <> | 2011-04-18 22:11:31 +0000 |
| commit | 374f79f160c3bf7a7ae9bdfe665a152c75ee9437 (patch) | |
| tree | e7f5265e329c87f555dea09d8e1e25fd3f16699b /nova/api | |
| parent | 9eb273546e1b7b820a8e687fe7027d9db3d9b1d3 (diff) | |
| parent | 690ace3417c717cd8c363ee714e780c2ef06d4ab (diff) | |
Support admin password when specified in server create requests.
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/servers.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 43e0c7963..3d39a9cf4 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -118,6 +118,8 @@ class Controller(common.OpenstackController): context = req.environ['nova.context'] + password = self._get_server_admin_password(env['server']) + key_name = None key_data = None key_pairs = auth_manager.AuthManager.get_key_pairs(context) @@ -180,7 +182,6 @@ class Controller(common.OpenstackController): builder = self._get_view_builder(req) server = builder.build(inst, is_detail=True) - password = utils.generate_password(16) server['server']['adminPass'] = password self.compute_api.set_admin_password(context, server['server']['id'], password) @@ -242,6 +243,10 @@ class Controller(common.OpenstackController): # if the original error is okay, just reraise it raise error + def _get_server_admin_password(self, server): + """ Determine the admin password for a server on creation """ + return utils.generate_password(16) + @scheduler_api.redirect_handler def update(self, req, id): """ Updates the server name or password """ @@ -648,6 +653,16 @@ class ControllerV11(Controller): def _limit_items(self, items, req): return common.limited_by_marker(items, req) + def _get_server_admin_password(self, server): + """ Determine the admin password for a server on creation """ + password = server.get('adminPass') + if password is None: + return utils.generate_password(16) + if not isinstance(password, basestring) or password == '': + msg = _("Invalid adminPass") + raise exc.HTTPBadRequest(msg) + return password + def get_default_xmlns(self, req): return common.XML_NS_V11 |
