From 30d5f14a700dd53d80e0fbedefd9b1ad337390f9 Mon Sep 17 00:00:00 2001 From: Artem Goncharov Date: Sat, 5 Dec 2020 15:40:24 +0100 Subject: [PATCH] Add support for token caching SDK starts caching token in keyring (when available and configured). A small change is required in OSC not to reject this state. Overall this helps avoiding reauthentication upon next openstack call. If token is not valid anymore automatically reauthentication is done. Depends-On: https://review.opendev.org/c/openstack/openstacksdk/+/735352 Depends-On: https://review.opendev.org/c/openstack/osc-lib/+/765650 Change-Id: I47261a32bd3b106a589974d3de5bf2a6ebd57263 --- openstackclient/common/clientmanager.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/openstackclient/common/clientmanager.py b/openstackclient/common/clientmanager.py index 36c3ce268..1ed6aa240 100644 --- a/openstackclient/common/clientmanager.py +++ b/openstackclient/common/clientmanager.py @@ -83,10 +83,12 @@ class ClientManager(clientmanager.ClientManager): self._cli_options._openstack_config._pw_callback = \ shell.prompt_for_password try: - self._cli_options._auth = \ - self._cli_options._openstack_config.load_auth_plugin( - self._cli_options.config, - ) + # We might already get auth from SDK caching + if not self._cli_options._auth: + self._cli_options._auth = \ + self._cli_options._openstack_config.load_auth_plugin( + self._cli_options.config, + ) except TypeError as e: self._fallback_load_auth_plugin(e)