From 5521e4c504c6a3a06f17a9e4f80444743aa293c7 Mon Sep 17 00:00:00 2001 From: Roxana Gherle Date: Fri, 22 May 2015 16:22:35 -0700 Subject: Add --os-endpoint-type cli optional argument User should be able to specify the endpoint type through a CLI optional argument/ENV variable setting. We will name this new optional argument: --os-endpoint-type (Env: OS_ENDPOINT_TYPE) and based on the value given, the service API will use that specific endpoint type. Possible values: public, admin, internal. DocImpact Closes-Bug: #1454392 Change-Id: Ife3d4e46b44c0ddcd712b1130e27e362545a9a29 --- openstackclient/common/clientmanager.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'openstackclient/common/clientmanager.py') diff --git a/openstackclient/common/clientmanager.py b/openstackclient/common/clientmanager.py index 6311c71a..2a57b8ff 100644 --- a/openstackclient/common/clientmanager.py +++ b/openstackclient/common/clientmanager.py @@ -86,6 +86,7 @@ class ClientManager(object): self._pw_callback = pw_func self._url = self._cli_options.auth.get('url', None) self._region_name = self._cli_options.region_name + self._endpoint_type = self._cli_options.endpoint_type self.timing = self._cli_options.timing @@ -181,18 +182,23 @@ class ClientManager(object): self._auth_ref = self.auth.get_auth_ref(self.session) return self._auth_ref - def get_endpoint_for_service_type(self, service_type, region_name=None): + def get_endpoint_for_service_type(self, service_type, region_name=None, + endpoint_type='public'): """Return the endpoint URL for the service type.""" + if not endpoint_type: + endpoint_type = 'public' # See if we are using password flow auth, i.e. we have a # service catalog to select endpoints from if self.auth_ref: endpoint = self.auth_ref.service_catalog.url_for( service_type=service_type, region_name=region_name, + endpoint_type=endpoint_type, ) else: # Get the passed endpoint directly from the auth plugin - endpoint = self.auth.get_endpoint(self.session) + endpoint = self.auth.get_endpoint(self.session, + interface=endpoint_type) return endpoint -- cgit v1.2.1