diff options
author | Jenkins <jenkins@review.openstack.org> | 2016-09-13 00:47:41 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2016-09-13 00:47:41 +0000 |
commit | 7d401cd5a6537a9c6296d67e33addcc20a62eeb6 (patch) | |
tree | 0340b6ebab7f790e1607bcb8649cdb996305a16e | |
parent | b0d2f4d4ad309faf72705d79cbc368e98c85ba6e (diff) | |
parent | 8b7859e21e64027d20f158737bbf70bbe409b847 (diff) | |
download | os-client-config-7d401cd5a6537a9c6296d67e33addcc20a62eeb6.tar.gz |
Merge "Split auth plugin loading into its own method"
-rw-r--r-- | os_client_config/config.py | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/os_client_config/config.py b/os_client_config/config.py index 0c11230..646e55d 100644 --- a/os_client_config/config.py +++ b/os_client_config/config.py @@ -1032,6 +1032,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 @@ -1090,21 +1108,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 |