summaryrefslogtreecommitdiff
path: root/openstackclient/common
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-07-03 02:48:47 +0000
committerGerrit Code Review <review@openstack.org>2015-07-03 02:48:47 +0000
commitee64c2fa6b9eb6f8d628e8899df39a4ee01c2bb3 (patch)
tree57e047252b843c67eef60fa4a1a8358dbac9f173 /openstackclient/common
parentd80deaba41d09534a3f5a670957b4b0d035509b6 (diff)
parent5521e4c504c6a3a06f17a9e4f80444743aa293c7 (diff)
downloadpython-openstackclient-ee64c2fa6b9eb6f8d628e8899df39a4ee01c2bb3.tar.gz
Merge "Add --os-endpoint-type cli optional argument"
Diffstat (limited to 'openstackclient/common')
-rw-r--r--openstackclient/common/clientmanager.py10
-rw-r--r--openstackclient/common/utils.py8
2 files changed, 16 insertions, 2 deletions
diff --git a/openstackclient/common/clientmanager.py b/openstackclient/common/clientmanager.py
index 0159ad7d..fae95630 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
@@ -183,18 +184,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
diff --git a/openstackclient/common/utils.py b/openstackclient/common/utils.py
index c824678e..6cd35c05 100644
--- a/openstackclient/common/utils.py
+++ b/openstackclient/common/utils.py
@@ -368,3 +368,11 @@ def read_blob_file_contents(blob_file):
except IOError:
msg = "Error occurred trying to read from file %s"
raise exceptions.CommandError(msg % blob_file)
+
+
+def build_kwargs_dict(arg_name, value):
+ """Return a dictionary containing `arg_name` if `value` is set."""
+ kwargs = {}
+ if value:
+ kwargs[arg_name] = value
+ return kwargs