summaryrefslogtreecommitdiff
path: root/troveclient/client.py
diff options
context:
space:
mode:
authorAmrith Kumar <amrith@tesora.com>2014-11-10 12:25:29 -0500
committerAmrith Kumar <amrith@tesora.com>2014-11-10 12:25:29 -0500
commitd4c28878549967258bf7a0ad5dc0ebdde9ff4ddd (patch)
tree6abb89b562be1db0aba98ed54691ffea80e03176 /troveclient/client.py
parent3c47a1855b7ee1345dadfb00ae90a6279b7c424e (diff)
downloadpython-troveclient-d4c28878549967258bf7a0ad5dc0ebdde9ff4ddd.tar.gz
Reverse fix for 1323866 as it regressed trove CLI
Trove CLI appears to be broken (fresh checkout, devstack as well as openstack gate). All commands fail with ERROR: __init__() got an unexpected keyword argument 'http_log_debug' Correcting the obvious place where this appears to be an issue is causing additional failures and as it is time-critical to get this back up and running, I'm proposing a reversal of the change from 3c47a1855b7ee1345dadfb00ae90a6279b7c424e while that change is completely reworked. I will ping trove core for an approval on this and if I don't get an approval, I'll fast track this reversal. Change-Id: Icac028cfafac57c7e3ef03d4277ae2b7833bf58f Partial-Bug: 1391840
Diffstat (limited to 'troveclient/client.py')
-rw-r--r--troveclient/client.py105
1 files changed, 13 insertions, 92 deletions
diff --git a/troveclient/client.py b/troveclient/client.py
index 8280ae2..25a2235 100644
--- a/troveclient/client.py
+++ b/troveclient/client.py
@@ -25,7 +25,6 @@ import logging
import os
import requests
-from keystoneclient import adapter
from troveclient.openstack.common.apiclient import client
from troveclient.openstack.common.apiclient import exceptions
from troveclient import service_catalog
@@ -51,21 +50,7 @@ if not hasattr(urlparse, 'parse_qsl'):
urlparse.parse_qsl = cgi.parse_qsl
-class TroveClientMixin(object):
-
- def get_database_api_version_from_endpoint(self):
- magic_tuple = urlparse.urlsplit(self.management_url)
- scheme, netloc, path, query, frag = magic_tuple
- v = path.split("/")[1]
- valid_versions = ['v1.0']
- if v not in valid_versions:
- msg = "Invalid client version '%s'. must be one of: %s" % (
- (v, ', '.join(valid_versions)))
- raise exceptions.UnsupportedVersion(msg)
- return v[1:]
-
-
-class HTTPClient(TroveClientMixin):
+class HTTPClient(object):
USER_AGENT = 'python-troveclient'
@@ -74,17 +59,7 @@ class HTTPClient(TroveClientMixin):
proxy_token=None, region_name=None,
endpoint_type='publicURL', service_type=None,
service_name=None, database_service_name=None, retries=None,
- http_log_debug=False, cacert=None, bypass_url=None,
- auth_system='keystone', auth_plugin=None):
-
- if auth_system and auth_system != 'keystone' and not auth_plugin:
- raise exceptions.AuthSystemNotFound(auth_system)
-
- if not auth_url and auth_system and auth_system != 'keystone':
- auth_url = auth_plugin.get_auth_url()
- if not auth_url:
- raise exceptions.EndpointNotFound()
-
+ http_log_debug=False, cacert=None, bypass_url=None):
self.user = user
self.password = password
self.projectid = projectid
@@ -114,9 +89,6 @@ class HTTPClient(TroveClientMixin):
else:
self.verify_cert = True
- self.auth_system = auth_system
- self.auth_plugin = auth_plugin
-
self._logger = logging.getLogger(__name__)
if self.http_log_debug and not self._logger.handlers:
ch = logging.StreamHandler()
@@ -279,6 +251,7 @@ class HTTPClient(TroveClientMixin):
except exceptions.EndpointNotFound:
print("Could not find any suitable endpoint. Correct region?")
raise
+
elif resp.status_code == 305:
return resp['location']
else:
@@ -340,7 +313,6 @@ class HTTPClient(TroveClientMixin):
# with the endpoints any more, we need to replace
# our service account token with the user token.
self.auth_token = self.proxy_token
-
else:
try:
while auth_url:
@@ -416,67 +388,16 @@ class HTTPClient(TroveClientMixin):
return self._extract_service_catalog(url, resp, body)
-
-class SessionClient(adapter.LegacyJsonAdapter):
-
- def request(self, url, method, **kwargs):
- # NOTE(jamielennox): The standard call raises errors from
- # keystoneclient, where we need to raise the novaclient errors.
- raise_exc = kwargs.pop('raise_exc', True)
- resp, body = super(SessionClient, self).request(url,
- method,
- raise_exc=False,
- **kwargs)
-
- if raise_exc and resp.status_code >= 400:
- raise exceptions.from_response(resp, body, url, method)
-
- return resp, body
-
-
-def _construct_http_client(username=None, password=None, project_id=None,
- auth_url=None, insecure=False, timeout=None,
- proxy_tenant_id=None, proxy_token=None,
- region_name=None, endpoint_type='publicURL',
- service_type='database',
- service_name=None, database_service_name=None,
- retries=None,
- http_log_debug=False,
- auth_system='keystone', auth_plugin=None,
- cacert=None, tenant_id=None,
- session=None,
- auth=None):
- if session:
- return SessionClient(session=session,
- auth=auth,
- interface=endpoint_type,
- service_type=service_type,
- service_name=service_name,
- region_name=region_name,
- http_log_debug=http_log_debug)
-
- # FIXME(jamielennox): username and password are now optional. Need
- # to test that they were provided in this mode.
- 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,
- auth_system=auth_system,
- auth_plugin=auth_plugin,
- )
+ def get_database_api_version_from_endpoint(self):
+ magic_tuple = urlparse.urlsplit(self.management_url)
+ scheme, netloc, path, query, frag = magic_tuple
+ v = path.split("/")[1]
+ valid_versions = ['v1.0']
+ if v not in valid_versions:
+ msg = "Invalid client version '%s'. must be one of: %s" % (
+ (v, ', '.join(valid_versions)))
+ raise exceptions.UnsupportedVersion(msg)
+ return v[1:]
def get_version_map():