Add accessor method to pull URLs from the catalog

It's handy sometimes and the specifics of how to do so is complex.

Change-Id: I90d5c8c2709cf9d8bd76c3dbcbe171c7d75572a8
This commit is contained in:
Monty Taylor 2017-02-10 09:43:18 -06:00
parent eee55a8966
commit 4f98c8b23d
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594
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

@ -122,11 +122,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)