summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty Taylor <mordred@inaugust.com>2016-09-01 09:10:03 -0500
committerMonty Taylor <mordred@inaugust.com>2016-09-01 09:21:19 -0500
commit8b7859e21e64027d20f158737bbf70bbe409b847 (patch)
tree323d090c05a283aff590836d6d1577ecc0d8ac3a
parent42885dc94176eecca1619d7e9c33b5ab3d9a2c0a (diff)
downloados-client-config-8b7859e21e64027d20f158737bbf70bbe409b847.tar.gz
Split auth plugin loading into its own method
In case someone wants to do validate=False at get_one_cloud time, but still would like to get an auth plugin, having this block be its own method is handy. Change-Id: I26137391e67d60d8737473d3d4c6ed15dad53af1
-rw-r--r--os_client_config/config.py34
1 files changed, 19 insertions, 15 deletions
diff --git a/os_client_config/config.py b/os_client_config/config.py
index 6eed0f0..7a70daa 100644
--- a/os_client_config/config.py
+++ b/os_client_config/config.py
@@ -1031,6 +1031,24 @@ class OpenStackConfig(object):
return config
+ def load_auth_plugin(self, config, cloud):
+ try:
+ loader = self._get_auth_loader(config)
+ config = self._validate_auth(config, loader)
+ auth_plugin = loader.load_from_options(**config['auth'])
+ except Exception as e:
+ # We WANT the ksa exception normally
+ # but OSC can't handle it right now, so we try deferring
+ # to ksc. If that ALSO fails, it means there is likely
+ # a deeper issue, so we assume the ksa error was correct
+ self.log.debug("Deferring keystone exception: {e}".format(e=e))
+ auth_plugin = None
+ try:
+ config = self._validate_auth_ksc(config, cloud)
+ except Exception:
+ raise e
+ return auth_plugin
+
def get_one_cloud(self, cloud=None, validate=True,
argparse=None, **kwargs):
"""Retrieve a single cloud configuration and merge additional options
@@ -1089,21 +1107,7 @@ class OpenStackConfig(object):
config = self.auth_config_hook(config)
if validate:
- try:
- loader = self._get_auth_loader(config)
- config = self._validate_auth(config, loader)
- auth_plugin = loader.load_from_options(**config['auth'])
- except Exception as e:
- # We WANT the ksa exception normally
- # but OSC can't handle it right now, so we try deferring
- # to ksc. If that ALSO fails, it means there is likely
- # a deeper issue, so we assume the ksa error was correct
- self.log.debug("Deferring keystone exception: {e}".format(e=e))
- auth_plugin = None
- try:
- config = self._validate_auth_ksc(config, cloud)
- except Exception:
- raise e
+ auth_plugin = self.load_auth_plugin(config, cloud)
else:
auth_plugin = None