From 0069adef5ccec501c36b8da1d2de2821a97afe07 Mon Sep 17 00:00:00 2001 From: Mouad Benchchaoui Date: Thu, 10 Jul 2014 13:23:35 +0200 Subject: Add action 'user password set' for identiy v3 This new action will allow a user to change their own password by either providing the new password as an argument (--password) or by being prompted to enter the new password. In both cases user will be prompted to enter their current password as required by the v3 API. Closes-Bug: #1337245 Change-Id: I5e1e0fd2b46a4502318da57f7cce2b236fb2d93d --- openstackclient/identity/v3/user.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'openstackclient/identity') diff --git a/openstackclient/identity/v3/user.py b/openstackclient/identity/v3/user.py index 38c34973..6ba54368 100644 --- a/openstackclient/identity/v3/user.py +++ b/openstackclient/identity/v3/user.py @@ -323,6 +323,35 @@ class SetUser(command.Command): return +class SetPasswordUser(command.Command): + """Change current user password""" + + log = logging.getLogger(__name__ + '.SetPasswordUser') + + def get_parser(self, prog_name): + parser = super(SetPasswordUser, self).get_parser(prog_name) + parser.add_argument( + '--password', + metavar='', + help='New user password' + ) + return parser + + def take_action(self, parsed_args): + self.log.debug('take_action(%s)', parsed_args) + identity_client = self.app.client_manager.identity + + current_password = utils.get_password( + self.app.stdin, prompt="Current Password:", confirm=False) + + password = parsed_args.password + if password is None: + password = utils.get_password( + self.app.stdin, prompt="New Password:") + + identity_client.users.update_password(current_password, password) + + class ShowUser(show.ShowOne): """Show user details""" -- cgit v1.2.1