diff options
-rw-r--r-- | os_client_config/cloud_config.py | 16 | ||||
-rw-r--r-- | requirements.txt | 1 |
2 files changed, 17 insertions, 0 deletions
diff --git a/os_client_config/cloud_config.py b/os_client_config/cloud_config.py index f60303b..c9f9f07 100644 --- a/os_client_config/cloud_config.py +++ b/os_client_config/cloud_config.py @@ -14,6 +14,8 @@ import warnings +from keystoneauth1 import loading + class CloudConfig(object): def __init__(self, name, region, config, prefer_ipv6=False): @@ -106,3 +108,17 @@ class CloudConfig(object): @property def prefer_ipv6(self): return self._prefer_ipv6 + + def get_auth(self): + """Return a keystoneauth plugin from the auth credentials.""" + # Re-use the admin_token plugin for the "None" plugin + # since it does not look up endpoints or tokens but rather + # does a passthrough. This is useful for things like Ironic + # that have a keystoneless operational mode, but means we're + # still dealing with a keystoneauth Session object, so all the + # _other_ things (SSL arg handling, timeout) all work consistently + if self.config['auth_type'] in (None, "None", ''): + self.config['auth_type'] = 'admin_token' + self.config['auth']['token'] = None + loader = loading.get_plugin_loader(self.config['auth_type']) + return loader.load_from_options(**self.config['auth']) diff --git a/requirements.txt b/requirements.txt index 894a70a..db0b635 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ # process, which may cause wedges in the gate later. PyYAML>=3.1.0 appdirs>=1.3.0 +keystoneauth1>=1.0.0 |