From 9835daf9f684556c5aed4834dc086e932788f9bc Mon Sep 17 00:00:00 2001
From: Monty Taylor <mordred@inaugust.com>
Date: Fri, 8 Jan 2016 20:24:17 -0500
Subject: [PATCH] Add barbicanclient support

barbicanclient is a lovely client library, so we should add support
for make_legacy_client to doing the right things constructing a Client
object.

Change-Id: Idf015b1119ef76b951c195a6498cbb7a928d6e44
---
 os_client_config/cloud_config.py   | 7 +++++--
 os_client_config/constructors.json | 1 +
 os_client_config/defaults.json     | 1 +
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/os_client_config/cloud_config.py b/os_client_config/cloud_config.py
index f73da04..3b9bee9 100644
--- a/os_client_config/cloud_config.py
+++ b/os_client_config/cloud_config.py
@@ -305,7 +305,7 @@ class CloudConfig(object):
         endpoint_override = self.get_endpoint(service_key)
 
         if not interface_key:
-            if service_key == 'image':
+            if service_key in ('image', 'key-manager'):
                 interface_key = 'interface'
             else:
                 interface_key = 'endpoint_type'
@@ -348,7 +348,10 @@ class CloudConfig(object):
                 if 'endpoint' not in constructor_kwargs:
                     endpoint = self.get_session_endpoint('identity')
                     constructor_kwargs['endpoint'] = endpoint
-            constructor_args.append(version)
+            if service_key == 'key-manager':
+                constructor_kwargs['version'] = version
+            else:
+                constructor_args.append(version)
 
         return client_class(*constructor_args, **constructor_kwargs)
 
diff --git a/os_client_config/constructors.json b/os_client_config/constructors.json
index be44339..89c844c 100644
--- a/os_client_config/constructors.json
+++ b/os_client_config/constructors.json
@@ -3,6 +3,7 @@
     "database": "troveclient.client.Client",
     "identity": "keystoneclient.client.Client",
     "image": "glanceclient.Client",
+    "key-manager": "barbicanclient.client.Client",
     "metering": "ceilometerclient.client.Client",
     "network": "neutronclient.neutron.client.Client",
     "object-store": "swiftclient.client.Connection",
diff --git a/os_client_config/defaults.json b/os_client_config/defaults.json
index 2ffb672..f501862 100644
--- a/os_client_config/defaults.json
+++ b/os_client_config/defaults.json
@@ -12,6 +12,7 @@
   "image_api_use_tasks": false,
   "image_api_version": "2",
   "image_format": "qcow2",
+  "key_manager_api_version": "v1",
   "metering_api_version": "2",
   "network_api_version": "2",
   "object_store_api_version": "1",