diff options
| author | Mouad Benchchaoui <m.benchchaoui@x-ion.de> | 2014-07-10 13:23:35 +0200 |
|---|---|---|
| committer | Steve Martinelli <stevemar@ca.ibm.com> | 2014-09-07 02:37:54 -0400 |
| commit | 0069adef5ccec501c36b8da1d2de2821a97afe07 (patch) | |
| tree | 6d4cb9db017547989aa225281e28221d8c6f3341 /openstackclient/identity/v3 | |
| parent | 8e12949958143e7db9783ef6246e6b09def0ad8e (diff) | |
| download | python-openstackclient-0069adef5ccec501c36b8da1d2de2821a97afe07.tar.gz | |
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
Diffstat (limited to 'openstackclient/identity/v3')
| -rw-r--r-- | openstackclient/identity/v3/user.py | 29 |
1 files changed, 29 insertions, 0 deletions
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='<new-password>', + 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""" |
