diff options
author | Richard Lee <rblee88@gmail.com> | 2014-03-06 17:30:28 -0600 |
---|---|---|
committer | Anderson Mesquita <andersonvom@gmail.com> | 2014-03-07 10:59:24 -0600 |
commit | 3f120f6ba241c5bfb5da4676744204ac0ba4d1cc (patch) | |
tree | cd08a7775a5e0b9b42d435dc38f70b5021484be5 /barbicanclient/common/auth.py | |
parent | ecc4f2eb7b8a930d1059cdd5ae2c99e4d4d4df5e (diff) | |
download | python-barbicanclient-3f120f6ba241c5bfb5da4676744204ac0ba4d1cc.tar.gz |
Conditionally validate KeystoneAuthV2 credentials
Don't validate the presence of KeystoneAuthV2 credential info if a
keystone client is given.
Co-Authored-By: Anderson Mesquita <andersonvom@gmail.com>
Change-Id: I5d928efda843d8a6310103bf07c375d716908031
Diffstat (limited to 'barbicanclient/common/auth.py')
-rw-r--r-- | barbicanclient/common/auth.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/barbicanclient/common/auth.py b/barbicanclient/common/auth.py index ff26ddb..9711ac2 100644 --- a/barbicanclient/common/auth.py +++ b/barbicanclient/common/auth.py @@ -51,20 +51,23 @@ class AuthPluginBase(object): class KeystoneAuthV2(AuthPluginBase): def __init__(self, auth_url='', username='', password='', tenant_name='', tenant_id='', insecure=False, keystone=None): - if not all([auth_url, username, password, tenant_name or tenant_id]): - raise ValueError('Please provide auth_url, username, password,' - ' and tenant_id or tenant_name.') + if not keystone: + tenant_info = tenant_name or tenant_id + if not all([auth_url, username, password, tenant_info]): + raise ValueError('Please provide auth_url, username, password,' + ' and tenant_id or tenant_name.') + + self._barbican_url = None + #TODO(dmend): make these configurable + self._service_type = 'keystore' + self._endpoint_type = 'publicURL' + self._keystone = keystone or ksclient.Client(username=username, password=password, tenant_name=tenant_name, tenant_id=tenant_id, auth_url=auth_url, insecure=insecure) - self._barbican_url = None - #TODO(dmend): make these configurable - self._service_type = 'keystore' - self._endpoint_type = 'publicURL' - self.tenant_name = self._keystone.tenant_name self.tenant_id = self._keystone.tenant_id |