summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-10-12 23:50:03 +0000
committerGerrit Code Review <review@openstack.org>2016-10-12 23:50:03 +0000
commit6c252384c2cff4eef68d93e33d9bf81c9b768d38 (patch)
tree8585f1e43044fdd1c8183239052cd81a6f0f0fa3
parent3777f11003788ec7b443004a8626ceb5ec812e4f (diff)
parentf484736b7d087115b8330ae794c101f7f8e7b926 (diff)
downloados-client-config-6c252384c2cff4eef68d93e33d9bf81c9b768d38.tar.gz
Merge "cloud_config:get_session_endpoint: catch Keystone EndpointNotFound"1.22.0
-rw-r--r--os_client_config/cloud_config.py18
-rw-r--r--os_client_config/tests/test_cloud_config.py9
2 files changed, 22 insertions, 5 deletions
diff --git a/os_client_config/cloud_config.py b/os_client_config/cloud_config.py
index 80cd266..147eb04 100644
--- a/os_client_config/cloud_config.py
+++ b/os_client_config/cloud_config.py
@@ -16,6 +16,7 @@ import importlib
import warnings
from keystoneauth1 import adapter
+import keystoneauth1.exceptions.catalog
from keystoneauth1 import plugin
from keystoneauth1 import session
import requestsexceptions
@@ -251,11 +252,18 @@ class CloudConfig(object):
if service_key == 'identity':
endpoint = session.get_endpoint(interface=plugin.AUTH_INTERFACE)
else:
- endpoint = session.get_endpoint(
- service_type=self.get_service_type(service_key),
- service_name=self.get_service_name(service_key),
- interface=self.get_interface(service_key),
- region_name=self.region)
+ args = {
+ 'service_type': self.get_service_type(service_key),
+ 'service_name': self.get_service_name(service_key),
+ 'interface': self.get_interface(service_key),
+ 'region_name': self.region
+ }
+ try:
+ endpoint = session.get_endpoint(**args)
+ except keystoneauth1.exceptions.catalog.EndpointNotFound:
+ self.log.warning("Keystone catalog entry not found (%s)",
+ args)
+ endpoint = None
return endpoint
def get_legacy_client(
diff --git a/os_client_config/tests/test_cloud_config.py b/os_client_config/tests/test_cloud_config.py
index 7a8b77a..2763f4d 100644
--- a/os_client_config/tests/test_cloud_config.py
+++ b/os_client_config/tests/test_cloud_config.py
@@ -12,6 +12,7 @@
import copy
+from keystoneauth1 import exceptions as ksa_exceptions
from keystoneauth1 import plugin as ksa_plugin
from keystoneauth1 import session as ksa_session
import mock
@@ -235,6 +236,14 @@ class TestCloudConfig(base.TestCase):
region_name='region-al',
service_type='orchestration')
+ @mock.patch.object(cloud_config.CloudConfig, 'get_session')
+ def test_session_endpoint_not_found(self, mock_get_session):
+ exc_to_raise = ksa_exceptions.catalog.EndpointNotFound
+ mock_get_session.return_value.get_endpoint.side_effect = exc_to_raise
+ cc = cloud_config.CloudConfig(
+ "test1", "region-al", {}, auth_plugin=mock.Mock())
+ self.assertIsNone(cc.get_session_endpoint('notfound'))
+
@mock.patch.object(cloud_config.CloudConfig, 'get_api_version')
@mock.patch.object(cloud_config.CloudConfig, 'get_auth_args')
@mock.patch.object(cloud_config.CloudConfig, 'get_session_endpoint')