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/common/utils.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'openstackclient/common') diff --git a/openstackclient/common/utils.py b/openstackclient/common/utils.py index 0258f931..54a06b04 100644 --- a/openstackclient/common/utils.py +++ b/openstackclient/common/utils.py @@ -233,12 +233,15 @@ def get_effective_log_level(): return min_log_lvl -def get_password(stdin): +def get_password(stdin, prompt=None, confirm=True): + message = prompt or "User Password:" if hasattr(stdin, 'isatty') and stdin.isatty(): try: while True: - first_pass = getpass.getpass("User password: ") - second_pass = getpass.getpass("Repeat user password: ") + first_pass = getpass.getpass(message) + if not confirm: + return first_pass + second_pass = getpass.getpass("Repeat " + message) if first_pass == second_pass: return first_pass print("The passwords entered were not the same") -- cgit v1.2.1