upstream/openstack/python-openstackclient/centos/patches/CGTS-7814-warning-only-when...

43 lines
1.9 KiB
Diff

From a2f2306ae12c65d0758a63781ace5d3e6cf0df7f Mon Sep 17 00:00:00 2001
From: jmckenna <jason.mckenna@windriver.com>
Date: Fri, 6 Oct 2017 10:40:12 -0400
Subject: [PATCH] [PATCH] CGTS-7814: warning only when the admin password
change accepted
Currently admin password change CLI warning coming even when new
Password Change is not accepted. The patch fixed this by moving
the warning from keystoneclient to openstackclienti, after the
password update call.
diff --git a/openstackclient/identity/v3/user.py b/openstackclient/identity/v3/user.py
index 201d217..e94ec1f 100644
--- a/openstackclient/identity/v3/user.py
+++ b/openstackclient/identity/v3/user.py
@@ -392,7 +392,7 @@ class SetUser(command.Command):
kwargs['enabled'] = False
identity_client.users.update(user.id, **kwargs)
- if user.name == 'admin' :
+ if user.name == 'admin' and 'password' in kwargs :
print("Warning: '%s' password changed. Please wait 5 minutes "
"before Locking/Unlocking the controllers for the password "
"change to come into effect\n" %(user.name))
@@ -456,6 +456,17 @@ class SetPasswordUser(command.Command):
identity_client.users.update_password(current_password, password)
+ # retrieve the authentication information from the cached token session
+ session_auth = identity_client.session.auth
+ username = ""
+ if "username" in session_auth.__dict__:
+ username = session_auth.username
+ elif "_username" in session_auth.__dict__:
+ username = session_auth._username
+ if username == 'admin' :
+ print("Warning: '%s' password changed. Please wait 5 minutes "
+ "before Locking/Unlocking the controllers for the password "
+ "change to come into effect\n" %(username))
class ShowUser(command.ShowOne):
_description = _("Display user details")