diff --git a/releasenotes/notes/endpoint-from-catalog-bad36cb0409a4e6a.yaml b/releasenotes/notes/endpoint-from-catalog-bad36cb0409a4e6a.yaml new file mode 100644 index 000000000..2db7bc947 --- /dev/null +++ b/releasenotes/notes/endpoint-from-catalog-bad36cb0409a4e6a.yaml @@ -0,0 +1,4 @@ +--- +features: + - Add new method, 'endpoint_for' which will return the + raw endpoint for a given service from the current catalog. diff --git a/shade/openstackcloud.py b/shade/openstackcloud.py index 19714c476..78124749f 100644 --- a/shade/openstackcloud.py +++ b/shade/openstackcloud.py @@ -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): diff --git a/shade/tests/unit/base.py b/shade/tests/unit/base.py index 788bb4b4e..1557d90eb 100644 --- a/shade/tests/unit/base.py +++ b/shade/tests/unit/base.py @@ -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)