summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--os_client_config/cloud_config.py16
-rw-r--r--os_client_config/constructors.json1
-rw-r--r--os_client_config/tests/test_cloud_config.py32
-rw-r--r--releasenotes/notes/fix-compat-with-old-keystoneauth-66e11ee9d008b962.yaml7
4 files changed, 47 insertions, 9 deletions
diff --git a/os_client_config/cloud_config.py b/os_client_config/cloud_config.py
index 0860924..5f7a34b 100644
--- a/os_client_config/cloud_config.py
+++ b/os_client_config/cloud_config.py
@@ -215,16 +215,26 @@ class CloudConfig(object):
requestsexceptions.squelch_warnings(insecure_requests=not verify)
self._keystone_session = self._session_constructor(
auth=self._auth,
- app_name=self._app_name,
- app_version=self._app_version,
verify=verify,
cert=cert,
timeout=self.config['api_timeout'])
if hasattr(self._keystone_session, 'additional_user_agent'):
self._keystone_session.additional_user_agent.append(
('os-client-config', os_client_config.__version__))
+ # Using old keystoneauth with new os-client-config fails if
+ # we pass in app_name and app_version. Those are not essential,
+ # nor a reason to bump our minimum, so just test for the session
+ # having the attribute post creation and set them then.
+ if hasattr(self._keystone_session, 'app_name'):
+ self._keystone_session.app_name = self._app_name
+ if hasattr(self._keystone_session, 'app_version'):
+ self._keystone_session.app_version = self._app_version
return self._keystone_session
+ def get_service_catalog(self):
+ """Helper method to grab the service catalog."""
+ return self._auth.get_access(self.get_session()).service_catalog
+
def get_session_client(self, service_key):
"""Return a prepped requests adapter for a given service.
@@ -361,7 +371,7 @@ class CloudConfig(object):
endpoint_override = self.get_endpoint(service_key)
if not interface_key:
- if service_key in ('image', 'key-manager', 'identity'):
+ if service_key in ('image', 'key-manager'):
interface_key = 'interface'
else:
interface_key = 'endpoint_type'
diff --git a/os_client_config/constructors.json b/os_client_config/constructors.json
index 2819bf3..9acb7cf 100644
--- a/os_client_config/constructors.json
+++ b/os_client_config/constructors.json
@@ -1,5 +1,6 @@
{
"application-catalog": "muranoclient.client.Client",
+ "baremetal": "ironicclient.client.Client",
"compute": "novaclient.client.Client",
"container-infra": "magnumclient.client.Client",
"database": "troveclient.client.Client",
diff --git a/os_client_config/tests/test_cloud_config.py b/os_client_config/tests/test_cloud_config.py
index 0671fcc..3ec7ecf 100644
--- a/os_client_config/tests/test_cloud_config.py
+++ b/os_client_config/tests/test_cloud_config.py
@@ -187,8 +187,29 @@ class TestCloudConfig(base.TestCase):
cc.get_session()
mock_session.assert_called_with(
auth=mock.ANY,
- verify=True, cert=None, timeout=None,
- app_name=None, app_version=None)
+ verify=True, cert=None, timeout=None)
+ self.assertEqual(
+ fake_session.additional_user_agent,
+ [('os-client-config', '1.2.3')])
+
+ @mock.patch.object(ksa_session, 'Session')
+ def test_get_session_with_app_name(self, mock_session):
+ config_dict = defaults.get_defaults()
+ config_dict.update(fake_services_dict)
+ fake_session = mock.Mock()
+ fake_session.additional_user_agent = []
+ fake_session.app_name = None
+ fake_session.app_version = None
+ mock_session.return_value = fake_session
+ cc = cloud_config.CloudConfig(
+ "test1", "region-al", config_dict, auth_plugin=mock.Mock(),
+ app_name="test_app", app_version="test_version")
+ cc.get_session()
+ mock_session.assert_called_with(
+ auth=mock.ANY,
+ verify=True, cert=None, timeout=None)
+ self.assertEqual(fake_session.app_name, "test_app")
+ self.assertEqual(fake_session.app_version, "test_version")
self.assertEqual(
fake_session.additional_user_agent,
[('os-client-config', '1.2.3')])
@@ -206,8 +227,7 @@ class TestCloudConfig(base.TestCase):
cc.get_session()
mock_session.assert_called_with(
auth=mock.ANY,
- verify=True, cert=None, timeout=9,
- app_name=None, app_version=None)
+ verify=True, cert=None, timeout=9)
self.assertEqual(
fake_session.additional_user_agent,
[('os-client-config', '1.2.3')])
@@ -530,7 +550,7 @@ class TestCloudConfig(base.TestCase):
mock_client.assert_called_with(
version='2.0',
endpoint='http://example.com/v2',
- interface='admin',
+ endpoint_type='admin',
endpoint_override=None,
region_name='region-al',
service_type='identity',
@@ -550,7 +570,7 @@ class TestCloudConfig(base.TestCase):
mock_client.assert_called_with(
version='3',
endpoint='http://example.com',
- interface='admin',
+ endpoint_type='admin',
endpoint_override=None,
region_name='region-al',
service_type='identity',
diff --git a/releasenotes/notes/fix-compat-with-old-keystoneauth-66e11ee9d008b962.yaml b/releasenotes/notes/fix-compat-with-old-keystoneauth-66e11ee9d008b962.yaml
new file mode 100644
index 0000000..80d09fb
--- /dev/null
+++ b/releasenotes/notes/fix-compat-with-old-keystoneauth-66e11ee9d008b962.yaml
@@ -0,0 +1,7 @@
+---
+issues:
+ - Fixed a regression when using latest os-client-config with
+ the keystoneauth from stable/newton. Although this isn't a
+ super common combination, the added feature that broke the
+ interaction is really not worthy of the incompatibility, so
+ a workaround was added.