Rename client.py to httpclient.py
The discoverable entry point is to be client.Client however adding this functionality to the current client.py is impossible as we end up with circular dependencies. This patch simply renames the current client.py to httpclient.py to make future patches that will modify client.py more readable. Required for: blueprint api-version-discovery Change-Id: Ibcea03f6e1df0ae05329297166a8b8117fc3ce7b
This commit is contained in:

committed by
Jamie Lennox

parent
08d0ef8ee8
commit
b7c6f604e7
@@ -18,13 +18,13 @@
|
||||
import logging
|
||||
import urlparse
|
||||
|
||||
from keystoneclient import client
|
||||
from keystoneclient import exceptions
|
||||
from keystoneclient import httpclient
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Client(client.HTTPClient):
|
||||
class Client(httpclient.HTTPClient):
|
||||
"""Client for the OpenStack Keystone pre-version calls API.
|
||||
|
||||
:param string endpoint: A user-supplied endpoint URL for the keystone
|
||||
@@ -80,10 +80,10 @@ class Client(client.HTTPClient):
|
||||
def _check_keystone_versions(self, url):
|
||||
"""Calls Keystone URL and detects the available API versions."""
|
||||
try:
|
||||
httpclient = client.HTTPClient()
|
||||
resp, body = httpclient.request(url, "GET",
|
||||
headers={'Accept':
|
||||
'application/json'})
|
||||
client = httpclient.HTTPClient()
|
||||
resp, body = client.request(url, "GET",
|
||||
headers={'Accept':
|
||||
'application/json'})
|
||||
# Multiple Choices status code is returned by the root
|
||||
# identity endpoint, with references to one or more
|
||||
# Identity API versions -- v3 spec
|
||||
@@ -143,12 +143,12 @@ class Client(client.HTTPClient):
|
||||
def _check_keystone_extensions(self, url):
|
||||
"""Calls Keystone URL and detects the available extensions."""
|
||||
try:
|
||||
httpclient = client.HTTPClient()
|
||||
client = httpclient.HTTPClient()
|
||||
if not url.endswith("/"):
|
||||
url += '/'
|
||||
resp, body = httpclient.request("%sextensions" % url, "GET",
|
||||
headers={'Accept':
|
||||
'application/json'})
|
||||
resp, body = client.request("%sextensions" % url, "GET",
|
||||
headers={'Accept':
|
||||
'application/json'})
|
||||
if resp.status_code in (200, 204): # some cases we get No Content
|
||||
try:
|
||||
results = {}
|
||||
|
@@ -14,8 +14,8 @@
|
||||
# under the License.
|
||||
import logging
|
||||
|
||||
from keystoneclient import client
|
||||
from keystoneclient import exceptions
|
||||
from keystoneclient import httpclient
|
||||
from keystoneclient.v2_0 import ec2
|
||||
from keystoneclient.v2_0 import endpoints
|
||||
from keystoneclient.v2_0 import roles
|
||||
@@ -28,7 +28,7 @@ from keystoneclient.v2_0 import users
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Client(client.HTTPClient):
|
||||
class Client(httpclient.HTTPClient):
|
||||
"""Client for the OpenStack Keystone v2.0 API.
|
||||
|
||||
:param string username: Username for authentication. (optional)
|
||||
|
@@ -15,8 +15,8 @@
|
||||
import json
|
||||
import logging
|
||||
|
||||
from keystoneclient import client
|
||||
from keystoneclient import exceptions
|
||||
from keystoneclient import httpclient
|
||||
from keystoneclient.v3 import credentials
|
||||
from keystoneclient.v3 import domains
|
||||
from keystoneclient.v3 import endpoints
|
||||
@@ -31,7 +31,7 @@ from keystoneclient.v3 import users
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Client(client.HTTPClient):
|
||||
class Client(httpclient.HTTPClient):
|
||||
"""Client for the OpenStack Identity API v3.
|
||||
|
||||
:param string user_id: User ID for authentication. (optional)
|
||||
|
@@ -3,8 +3,8 @@ import mock
|
||||
|
||||
import requests
|
||||
|
||||
from keystoneclient import client
|
||||
from keystoneclient import exceptions
|
||||
from keystoneclient import httpclient
|
||||
from tests import utils
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ MOCK_REQUEST = mock.Mock(return_value=(FAKE_RESPONSE))
|
||||
|
||||
|
||||
def get_client():
|
||||
cl = client.HTTPClient(username="username", password="password",
|
||||
tenant_id="tenant", auth_url="auth_test")
|
||||
cl = httpclient.HTTPClient(username="username", password="password",
|
||||
tenant_id="tenant", auth_url="auth_test")
|
||||
return cl
|
||||
|
||||
|
||||
@@ -108,9 +108,9 @@ class ClientTest(utils.TestCase):
|
||||
|
||||
def test_forwarded_for(self):
|
||||
ORIGINAL_IP = "10.100.100.1"
|
||||
cl = client.HTTPClient(username="username", password="password",
|
||||
tenant_id="tenant", auth_url="auth_test",
|
||||
original_ip=ORIGINAL_IP)
|
||||
cl = httpclient.HTTPClient(username="username", password="password",
|
||||
tenant_id="tenant", auth_url="auth_test",
|
||||
original_ip=ORIGINAL_IP)
|
||||
|
||||
with mock.patch.object(requests, "request", MOCK_REQUEST):
|
||||
res = cl.request('/', 'GET')
|
||||
|
@@ -3,7 +3,7 @@ import mock
|
||||
|
||||
import requests
|
||||
|
||||
from keystoneclient import client
|
||||
from keystoneclient import httpclient
|
||||
from tests import utils
|
||||
|
||||
|
||||
@@ -15,9 +15,9 @@ MOCK_REQUEST = mock.Mock(return_value=(FAKE_RESPONSE))
|
||||
|
||||
|
||||
def get_client():
|
||||
cl = client.HTTPClient(username="username", password="password",
|
||||
tenant_id="tenant", auth_url="auth_test",
|
||||
cacert="ca.pem", key="key.pem", cert="cert.pem")
|
||||
cl = httpclient.HTTPClient(username="username", password="password",
|
||||
tenant_id="tenant", auth_url="auth_test",
|
||||
cacert="ca.pem", key="key.pem", cert="cert.pem")
|
||||
return cl
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ class ClientTest(utils.TestCase):
|
||||
|
||||
def test_post_auth(self):
|
||||
with mock.patch.object(requests, "request", MOCK_REQUEST):
|
||||
cl = client.HTTPClient(
|
||||
cl = httpclient.HTTPClient(
|
||||
username="username", password="password", tenant_id="tenant",
|
||||
auth_url="auth_test", cacert="ca.pem", key="key.pem",
|
||||
cert="cert.pem")
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import datetime
|
||||
|
||||
from keystoneclient import access
|
||||
from keystoneclient import client
|
||||
from keystoneclient import httpclient
|
||||
from keystoneclient.openstack.common import timeutils
|
||||
|
||||
from tests import utils
|
||||
@@ -58,8 +58,8 @@ class KeyringTest(utils.TestCase):
|
||||
Ensure that we get no value back if we don't have use_keyring
|
||||
set in the client.
|
||||
"""
|
||||
cl = client.HTTPClient(username=USERNAME, password=PASSWORD,
|
||||
tenant_id=TENANT_ID, auth_url=AUTH_URL)
|
||||
cl = httpclient.HTTPClient(username=USERNAME, password=PASSWORD,
|
||||
tenant_id=TENANT_ID, auth_url=AUTH_URL)
|
||||
|
||||
(keyring_key, auth_ref) = cl.get_auth_ref_from_keyring(
|
||||
auth_url=AUTH_URL,
|
||||
@@ -72,8 +72,8 @@ class KeyringTest(utils.TestCase):
|
||||
self.assertIsNone(auth_ref)
|
||||
|
||||
def test_build_keyring_key(self):
|
||||
cl = client.HTTPClient(username=USERNAME, password=PASSWORD,
|
||||
tenant_id=TENANT_ID, auth_url=AUTH_URL)
|
||||
cl = httpclient.HTTPClient(username=USERNAME, password=PASSWORD,
|
||||
tenant_id=TENANT_ID, auth_url=AUTH_URL)
|
||||
|
||||
keyring_key = cl._build_keyring_key(auth_url=AUTH_URL,
|
||||
username=USERNAME,
|
||||
@@ -86,9 +86,9 @@ class KeyringTest(utils.TestCase):
|
||||
(AUTH_URL, TENANT_ID, TENANT, TOKEN, USERNAME))
|
||||
|
||||
def test_set_and_get_keyring_expired(self):
|
||||
cl = client.HTTPClient(username=USERNAME, password=PASSWORD,
|
||||
tenant_id=TENANT_ID, auth_url=AUTH_URL,
|
||||
use_keyring=True)
|
||||
cl = httpclient.HTTPClient(username=USERNAME, password=PASSWORD,
|
||||
tenant_id=TENANT_ID, auth_url=AUTH_URL,
|
||||
use_keyring=True)
|
||||
keyring_key = cl._build_keyring_key(auth_url=AUTH_URL,
|
||||
username=USERNAME,
|
||||
tenant_name=TENANT,
|
||||
@@ -108,9 +108,9 @@ class KeyringTest(utils.TestCase):
|
||||
self.assertIsNone(auth_ref)
|
||||
|
||||
def test_set_and_get_keyring(self):
|
||||
cl = client.HTTPClient(username=USERNAME, password=PASSWORD,
|
||||
tenant_id=TENANT_ID, auth_url=AUTH_URL,
|
||||
use_keyring=True)
|
||||
cl = httpclient.HTTPClient(username=USERNAME, password=PASSWORD,
|
||||
tenant_id=TENANT_ID, auth_url=AUTH_URL,
|
||||
use_keyring=True)
|
||||
keyring_key = cl._build_keyring_key(auth_url=AUTH_URL,
|
||||
username=USERNAME,
|
||||
tenant_name=TENANT,
|
||||
|
@@ -5,7 +5,7 @@ import sys
|
||||
|
||||
from testtools import matchers
|
||||
|
||||
from keystoneclient import client
|
||||
from keystoneclient import httpclient
|
||||
|
||||
from tests import utils
|
||||
from tests.v2_0 import fakes
|
||||
@@ -28,11 +28,11 @@ class ShellTests(utils.TestCase):
|
||||
|
||||
self.fake_client = fakes.FakeHTTPClient()
|
||||
self.stubs.Set(
|
||||
client.HTTPClient, "_cs_request",
|
||||
httpclient.HTTPClient, "_cs_request",
|
||||
lambda ign_self, *args, **kwargs:
|
||||
self.fake_client._cs_request(*args, **kwargs))
|
||||
self.stubs.Set(
|
||||
client.HTTPClient, "authenticate",
|
||||
httpclient.HTTPClient, "authenticate",
|
||||
lambda cl_obj:
|
||||
self.fake_client.authenticate(cl_obj))
|
||||
self.old_environment = os.environ.copy()
|
||||
|
Reference in New Issue
Block a user