summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-01-12 15:15:18 +0000
committerGerrit Code Review <review@openstack.org>2016-01-12 15:15:18 +0000
commit570ed32fa1e07cacc7e8ad558858574ac6c28743 (patch)
tree3826ee090825a9fc60b4cef723373e1f5ccb3cbc
parentae9776c15ce56b01bfe9228abb4d336d9cec477d (diff)
parentf61a487fa13c8292b9fd3ac103e1133ac05dbd26 (diff)
downloados-client-config-570ed32fa1e07cacc7e8ad558858574ac6c28743.tar.gz
Merge "Use _get_client in make_client helper function"
-rw-r--r--os_client_config/__init__.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/os_client_config/__init__.py b/os_client_config/__init__.py
index ece1559..52fcb85 100644
--- a/os_client_config/__init__.py
+++ b/os_client_config/__init__.py
@@ -14,6 +14,7 @@
import sys
+from os_client_config import cloud_config
from os_client_config.config import OpenStackConfig # noqa
@@ -34,7 +35,7 @@ def simple_client(service_key, cloud=None, region_name=None):
cloud=cloud, region_name=region_name).get_session_client(service_key)
-def make_client(service_key, constructor, options=None, **kwargs):
+def make_client(service_key, constructor=None, options=None, **kwargs):
"""Simple wrapper for getting a client instance from a client lib.
OpenStack Client Libraries all have a fairly consistent constructor
@@ -44,6 +45,8 @@ def make_client(service_key, constructor, options=None, **kwargs):
variables and clouds.yaml - and takes as **kwargs anything you'd expect
to pass in.
"""
+ if not constructor:
+ constructor = cloud_config._get_client(service_key)
config = OpenStackConfig()
if options:
config.register_argparse_options(options, sys.argv, service_key)
@@ -51,5 +54,5 @@ def make_client(service_key, constructor, options=None, **kwargs):
else:
parsed_options = None
- cloud_config = config.get_one_cloud(options=parsed_options, **kwargs)
- return cloud_config.get_legacy_client(service_key, constructor)
+ cloud = config.get_one_cloud(options=parsed_options, **kwargs)
+ return cloud.get_legacy_client(service_key, constructor)