From f61a487fa13c8292b9fd3ac103e1133ac05dbd26 Mon Sep 17 00:00:00 2001
From: Monty Taylor <mordred@inaugust.com>
Date: Fri, 8 Jan 2016 20:38:35 -0500
Subject: [PATCH] Use _get_client in make_client helper function

We have a capability to know what constructor is needed for make_client,
but we didn't plumb it in. Make sure that the only thing needed is:

  os_client_config.make_client('compute')

Change-Id: I02aa1c46fa7cdfdb1409f8e1232e364b5ba48cd2
---
 os_client_config/__init__.py | 9 ++++++---
 1 file 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)