Merge "Add accessor method to pull URLs from the catalog"

This commit is contained in:
Jenkins 2017-02-15 14:20:42 +00:00 committed by Gerrit Code Review
commit 40b6d90f2b
3 changed files with 16 additions and 7 deletions

View File

@ -0,0 +1,4 @@
---
features:
- Add new method, 'endpoint_for' which will return the
raw endpoint for a given service from the current catalog.

View File

@ -566,9 +566,17 @@ class OpenStackCloud(_normalize.Normalizer):
return self._keystone_client
@property
def service_catalog(self):
def _keystone_catalog(self):
return self.keystone_session.auth.get_access(
self.keystone_session).service_catalog.catalog
self.keystone_session).service_catalog
@property
def service_catalog(self):
return self._keystone_catalog.catalog
def endpoint_for(self, service_type, interface='public'):
return self._keystone_catalog.url_for(
service_type=service_type, interface=interface)
@property
def auth_token(self):

View File

@ -136,11 +136,8 @@ class RequestsMockTestCase(BaseTestCase):
def get_mock_url(self, service_type, interface, resource=None,
append=None, base_url_append=None):
service_catalog = self.cloud.keystone_session.auth.get_access(
self.cloud.keystone_session).service_catalog
endpoint_url = service_catalog.url_for(
service_type=service_type,
interface=interface)
endpoint_url = self.cloud.endpoint_for(
service_type=service_type, interface=interface)
to_join = [endpoint_url]
if base_url_append:
to_join.append(base_url_append)