diff options
-rw-r--r-- | os_client_config/cloud_config.py | 5 | ||||
-rw-r--r-- | os_client_config/config.py | 6 |
2 files changed, 7 insertions, 4 deletions
diff --git a/os_client_config/cloud_config.py b/os_client_config/cloud_config.py index 1846f54..ae5da3a 100644 --- a/os_client_config/cloud_config.py +++ b/os_client_config/cloud_config.py @@ -70,7 +70,7 @@ def _make_key(key, service_type): class CloudConfig(object): def __init__(self, name, region, config, force_ipv4=False, auth_plugin=None, - openstack_config=None): + openstack_config=None, session_constructor=None): self.name = name self.region = region self.config = config @@ -79,6 +79,7 @@ class CloudConfig(object): self._auth = auth_plugin self._openstack_config = openstack_config self._keystone_session = None + self._session_constructor = session_constructor or session.Session def __getattr__(self, key): """Return arbitrary attributes.""" @@ -196,7 +197,7 @@ class CloudConfig(object): " since verify=False".format( cloud=self.name, region=self.region)) requestsexceptions.squelch_warnings(insecure_requests=not verify) - self._keystone_session = session.Session( + self._keystone_session = self._session_constructor( auth=self._auth, verify=verify, cert=cert, diff --git a/os_client_config/config.py b/os_client_config/config.py index 6eed0f0..0c11230 100644 --- a/os_client_config/config.py +++ b/os_client_config/config.py @@ -174,8 +174,9 @@ class OpenStackConfig(object): def __init__(self, config_files=None, vendor_files=None, override_defaults=None, force_ipv4=None, envvar_prefix=None, secure_files=None, - pw_func=None): + pw_func=None, session_constructor=None): self.log = _log.setup_logging(__name__) + self._session_constructor = session_constructor self._config_files = config_files or CONFIG_FILES self._secure_files = secure_files or SECURE_FILES @@ -1127,7 +1128,8 @@ class OpenStackConfig(object): config=self._normalize_keys(config), force_ipv4=force_ipv4, auth_plugin=auth_plugin, - openstack_config=self + openstack_config=self, + session_constructor=self._session_constructor, ) def get_one_cloud_osc( |