diff --git a/tobiko/openstack/keystone/__init__.py b/tobiko/openstack/keystone/__init__.py index 1a55b5fe0..eb9146f55 100644 --- a/tobiko/openstack/keystone/__init__.py +++ b/tobiko/openstack/keystone/__init__.py @@ -22,6 +22,7 @@ keystone_client = _client.keystone_client get_keystone_client = _client.get_keystone_client find_service = _client.find_service find_endpoint = _client.find_endpoint +find_service_endpoint = _client.find_service_endpoint list_endpoints = _client.list_endpoints list_services = _client.list_services KeystoneClientFixture = _client.KeystoneClientFixture diff --git a/tobiko/openstack/keystone/_client.py b/tobiko/openstack/keystone/_client.py index 7b254ce79..d8f77a9ce 100644 --- a/tobiko/openstack/keystone/_client.py +++ b/tobiko/openstack/keystone/_client.py @@ -174,6 +174,14 @@ def find_resources(resources, **params): yield resource +def find_service_endpoint(enabled=True, interface='public', client=None, + **params): + client = keystone_client(client) + service = find_service(client=client, enabled=enabled, **params) + return find_endpoint(client=client, service=service, interface=interface, + enabled=enabled) + + class KeystoneResourceNotFound(tobiko.TobikoException): message = 'No such resource found with parameters {params!r}' diff --git a/tobiko/tests/functional/openstack/test_keystone.py b/tobiko/tests/functional/openstack/test_keystone.py index 83421b065..cd6cfe21b 100644 --- a/tobiko/tests/functional/openstack/test_keystone.py +++ b/tobiko/tests/functional/openstack/test_keystone.py @@ -152,21 +152,17 @@ class KeystoneClientAPITest(testtools.TestCase): endpoint = keystone.find_endpoint(url=url) self.assertEqual(url, endpoint.url) - def test_find_keystone_public_endpoint(self): + def test_find_service_endpoint(self): service = keystone.find_service(name='keystone') - endpoint = keystone.find_endpoint(service=service, - interface='public', - enabled=True) + endpoint = keystone.find_service_endpoint(name='keystone') self.assertEqual(service.id, endpoint.service_id) self.assertEqual('public', endpoint.interface) self.assertTrue(endpoint.enabled) @keystone.skip_if_missing_service(name='octavia') - def test_find_octavia_public_endpoint(self): + def test_find_octavia_service_endpoint(self): service = keystone.find_service(name='octavia') - endpoint = keystone.find_endpoint(service=service, - interface='public', - enabled=True) + endpoint = keystone.find_service_endpoint(name='octavia') self.assertEqual(service.id, endpoint.service_id) self.assertEqual('public', endpoint.interface) self.assertTrue(endpoint.enabled)