Merge "Add ``insecure`` and ``cacert`` options to the client."

This commit is contained in:
Zuul 2018-09-07 10:00:10 +00:00 committed by Gerrit Code Review
commit a9eb87c436
2 changed files with 26 additions and 2 deletions

View File

@ -25,12 +25,26 @@ from cloudkittyclient.v1 import storage
class Client(object):
def __init__(self, session=None, adapter_options={}, **kwargs):
def __init__(self,
session=None,
adapter_options={},
cacert=None,
insecure=False,
**kwargs):
adapter_options.setdefault('service_type', 'rating')
if insecure:
verify_cert = False
else:
if cacert:
verify_cert = cacert
else:
verify_cert = True
self.session = session
if self.session is None:
self.session = ks_session.Session(**kwargs)
self.session = ks_session.Session(
verify=verify_cert, **kwargs)
self.api_client = adapter.Adapter(
session=self.session, **adapter_options)

View File

@ -49,6 +49,16 @@ Else, use it the same way as any other OpenStack client::
u'res_type': u'ALL',
u'tenant_id': u'bea6a24f77e946b0a92dca7c78b7870b'}]}
.. warning::
If you want to use SSL with the client as a python library, you need to
provide a cert to keystone's session object. Else, two additional options
are available if you provide an ``auth`` object to the client: ``insecure``
and ``cacert``::
>>> client = ck_client.Client(
'1', auth=auth, insecure=False, cacert='/path/to/ca')
When using the ``cloudkitty`` CLI client with keystone authentication, the
auth plugin to use should automagically be detected. If not, you can specify
the auth plugin to use with ``--os-auth-type/--os-auth-plugin``::