diff options
author | Jenkins <jenkins@review.openstack.org> | 2015-02-15 23:25:50 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2015-02-15 23:25:50 +0000 |
commit | 51aa1a8dbd1b45e6abdaf571d1d73a6d7405fd3a (patch) | |
tree | 42e6b7d97e60db9290c6e122a073bd2b5bda0b14 /troveclient/client.py | |
parent | 4acdad63ac54a3a2fac2fa9530a3d9c6d521f2c5 (diff) | |
parent | 2322d30706361792ff7a306fa678334dce11fd31 (diff) | |
download | python-troveclient-51aa1a8dbd1b45e6abdaf571d1d73a6d7405fd3a.tar.gz |
Merge "Pass all kwargs through to adapter"
Diffstat (limited to 'troveclient/client.py')
-rw-r--r-- | troveclient/client.py | 91 |
1 files changed, 44 insertions, 47 deletions
diff --git a/troveclient/client.py b/troveclient/client.py index f63cab0..daa0173 100644 --- a/troveclient/client.py +++ b/troveclient/client.py @@ -427,19 +427,21 @@ class HTTPClient(TroveClientMixin): class SessionClient(adapter.LegacyJsonAdapter, TroveClientMixin): - def __init__(self, session, auth, service_type=None, service_name=None, - region_name=None, endpoint_type='publicURL', - database_service_name=None, endpoint_override=None): - self.endpoint_type = endpoint_type - self.database_service_name = database_service_name - self.endpoint_override = endpoint_override + def __init__(self, session, auth, **kwargs): + self.database_service_name = kwargs.pop('database_service_name', None) + super(SessionClient, self).__init__(session=session, auth=auth, - interface=endpoint_type, - service_type=service_type, - service_name=service_name, - region_name=region_name) - self.management_url = self._get_endpoint_url() + **kwargs) + + # FIXME(jamielennox): this is going to cause an authentication request + # on client init. This is different to how the other clients work. + endpoint = self.get_endpoint() + + if not endpoint: + raise exceptions.EndpointNotFound() + + self.management_url = endpoint.rstrip('/') def request(self, url, method, **kwargs): raise_exc = kwargs.pop('raise_exc', True) @@ -453,16 +455,6 @@ class SessionClient(adapter.LegacyJsonAdapter, TroveClientMixin): return resp, body - def _get_endpoint_url(self): - endpoint_url = self.session.get_endpoint( - self.auth, interface=self.endpoint_type, - service_type=self.service_type) - - if not endpoint_url: - raise exceptions.EndpointNotFound - - return endpoint_url.rstrip('/') - def _construct_http_client(username=None, password=None, project_id=None, auth_url=None, insecure=False, timeout=None, @@ -475,37 +467,42 @@ def _construct_http_client(username=None, password=None, project_id=None, auth_system='keystone', auth_plugin=None, cacert=None, bypass_url=None, tenant_id=None, session=None, - auth=None): + **kwargs): if session: + try: + kwargs.setdefault('interface', endpoint_type) + except KeyError: + pass + return SessionClient(session=session, - auth=auth, service_type=service_type, service_name=service_name, region_name=region_name, - endpoint_type=endpoint_type, - database_service_name=database_service_name) - - return HTTPClient(username, - password, - projectid=project_id, - auth_url=auth_url, - insecure=insecure, - timeout=timeout, - tenant_id=tenant_id, - proxy_token=proxy_token, - proxy_tenant_id=proxy_tenant_id, - region_name=region_name, - endpoint_type=endpoint_type, - service_type=service_type, - service_name=service_name, - database_service_name=database_service_name, - retries=retries, - http_log_debug=http_log_debug, - cacert=cacert, - bypass_url=bypass_url, - auth_system=auth_system, - auth_plugin=auth_plugin, - ) + database_service_name=database_service_name, + connect_retries=retries, + **kwargs) + else: + return HTTPClient(username, + password, + projectid=project_id, + auth_url=auth_url, + insecure=insecure, + timeout=timeout, + tenant_id=tenant_id, + proxy_token=proxy_token, + proxy_tenant_id=proxy_tenant_id, + region_name=region_name, + endpoint_type=endpoint_type, + service_type=service_type, + service_name=service_name, + database_service_name=database_service_name, + retries=retries, + http_log_debug=http_log_debug, + cacert=cacert, + bypass_url=bypass_url, + auth_system=auth_system, + auth_plugin=auth_plugin, + ) def get_version_map(): |