Merge "Rename client.py to httpclient.py"

This commit is contained in:
Jenkins
2013-08-13 02:39:59 +00:00
committed by Gerrit Code Review
8 changed files with 39 additions and 39 deletions

View File

@@ -18,13 +18,13 @@
import logging import logging
import urlparse import urlparse
from keystoneclient import client
from keystoneclient import exceptions from keystoneclient import exceptions
from keystoneclient import httpclient
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
class Client(client.HTTPClient): class Client(httpclient.HTTPClient):
"""Client for the OpenStack Keystone pre-version calls API. """Client for the OpenStack Keystone pre-version calls API.
:param string endpoint: A user-supplied endpoint URL for the keystone :param string endpoint: A user-supplied endpoint URL for the keystone
@@ -80,8 +80,8 @@ class Client(client.HTTPClient):
def _check_keystone_versions(self, url): def _check_keystone_versions(self, url):
"""Calls Keystone URL and detects the available API versions.""" """Calls Keystone URL and detects the available API versions."""
try: try:
httpclient = client.HTTPClient() client = httpclient.HTTPClient()
resp, body = httpclient.request(url, "GET", resp, body = client.request(url, "GET",
headers={'Accept': headers={'Accept':
'application/json'}) 'application/json'})
# Multiple Choices status code is returned by the root # Multiple Choices status code is returned by the root
@@ -143,10 +143,10 @@ class Client(client.HTTPClient):
def _check_keystone_extensions(self, url): def _check_keystone_extensions(self, url):
"""Calls Keystone URL and detects the available extensions.""" """Calls Keystone URL and detects the available extensions."""
try: try:
httpclient = client.HTTPClient() client = httpclient.HTTPClient()
if not url.endswith("/"): if not url.endswith("/"):
url += '/' url += '/'
resp, body = httpclient.request("%sextensions" % url, "GET", resp, body = client.request("%sextensions" % url, "GET",
headers={'Accept': headers={'Accept':
'application/json'}) 'application/json'})
if resp.status_code in (200, 204): # some cases we get No Content if resp.status_code in (200, 204): # some cases we get No Content

View File

@@ -14,8 +14,8 @@
# under the License. # under the License.
import logging import logging
from keystoneclient import client
from keystoneclient import exceptions from keystoneclient import exceptions
from keystoneclient import httpclient
from keystoneclient.v2_0 import ec2 from keystoneclient.v2_0 import ec2
from keystoneclient.v2_0 import endpoints from keystoneclient.v2_0 import endpoints
from keystoneclient.v2_0 import roles from keystoneclient.v2_0 import roles
@@ -28,7 +28,7 @@ from keystoneclient.v2_0 import users
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
class Client(client.HTTPClient): class Client(httpclient.HTTPClient):
"""Client for the OpenStack Keystone v2.0 API. """Client for the OpenStack Keystone v2.0 API.
:param string username: Username for authentication. (optional) :param string username: Username for authentication. (optional)

View File

@@ -15,8 +15,8 @@
import json import json
import logging import logging
from keystoneclient import client
from keystoneclient import exceptions from keystoneclient import exceptions
from keystoneclient import httpclient
from keystoneclient.v3 import credentials from keystoneclient.v3 import credentials
from keystoneclient.v3 import domains from keystoneclient.v3 import domains
from keystoneclient.v3 import endpoints from keystoneclient.v3 import endpoints
@@ -31,7 +31,7 @@ from keystoneclient.v3 import users
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
class Client(client.HTTPClient): class Client(httpclient.HTTPClient):
"""Client for the OpenStack Identity API v3. """Client for the OpenStack Identity API v3.
:param string user_id: User ID for authentication. (optional) :param string user_id: User ID for authentication. (optional)

View File

@@ -3,8 +3,8 @@ import mock
import requests import requests
from keystoneclient import client
from keystoneclient import exceptions from keystoneclient import exceptions
from keystoneclient import httpclient
from tests import utils from tests import utils
@@ -16,7 +16,7 @@ MOCK_REQUEST = mock.Mock(return_value=(FAKE_RESPONSE))
def get_client(): def get_client():
cl = client.HTTPClient(username="username", password="password", cl = httpclient.HTTPClient(username="username", password="password",
tenant_id="tenant", auth_url="auth_test") tenant_id="tenant", auth_url="auth_test")
return cl return cl
@@ -108,7 +108,7 @@ class ClientTest(utils.TestCase):
def test_forwarded_for(self): def test_forwarded_for(self):
ORIGINAL_IP = "10.100.100.1" ORIGINAL_IP = "10.100.100.1"
cl = client.HTTPClient(username="username", password="password", cl = httpclient.HTTPClient(username="username", password="password",
tenant_id="tenant", auth_url="auth_test", tenant_id="tenant", auth_url="auth_test",
original_ip=ORIGINAL_IP) original_ip=ORIGINAL_IP)

View File

@@ -3,7 +3,7 @@ import mock
import requests import requests
from keystoneclient import client from keystoneclient import httpclient
from tests import utils from tests import utils
@@ -15,7 +15,7 @@ MOCK_REQUEST = mock.Mock(return_value=(FAKE_RESPONSE))
def get_client(): def get_client():
cl = client.HTTPClient(username="username", password="password", cl = httpclient.HTTPClient(username="username", password="password",
tenant_id="tenant", auth_url="auth_test", tenant_id="tenant", auth_url="auth_test",
cacert="ca.pem", key="key.pem", cert="cert.pem") cacert="ca.pem", key="key.pem", cert="cert.pem")
return cl return cl
@@ -71,7 +71,7 @@ class ClientTest(utils.TestCase):
def test_post_auth(self): def test_post_auth(self):
with mock.patch.object(requests, "request", MOCK_REQUEST): with mock.patch.object(requests, "request", MOCK_REQUEST):
cl = client.HTTPClient( cl = httpclient.HTTPClient(
username="username", password="password", tenant_id="tenant", username="username", password="password", tenant_id="tenant",
auth_url="auth_test", cacert="ca.pem", key="key.pem", auth_url="auth_test", cacert="ca.pem", key="key.pem",
cert="cert.pem") cert="cert.pem")

View File

@@ -1,7 +1,7 @@
import datetime import datetime
from keystoneclient import access from keystoneclient import access
from keystoneclient import client from keystoneclient import httpclient
from keystoneclient.openstack.common import timeutils from keystoneclient.openstack.common import timeutils
from tests import utils from tests import utils
@@ -58,7 +58,7 @@ class KeyringTest(utils.TestCase):
Ensure that we get no value back if we don't have use_keyring Ensure that we get no value back if we don't have use_keyring
set in the client. set in the client.
""" """
cl = client.HTTPClient(username=USERNAME, password=PASSWORD, cl = httpclient.HTTPClient(username=USERNAME, password=PASSWORD,
tenant_id=TENANT_ID, auth_url=AUTH_URL) tenant_id=TENANT_ID, auth_url=AUTH_URL)
(keyring_key, auth_ref) = cl.get_auth_ref_from_keyring( (keyring_key, auth_ref) = cl.get_auth_ref_from_keyring(
@@ -72,7 +72,7 @@ class KeyringTest(utils.TestCase):
self.assertIsNone(auth_ref) self.assertIsNone(auth_ref)
def test_build_keyring_key(self): def test_build_keyring_key(self):
cl = client.HTTPClient(username=USERNAME, password=PASSWORD, cl = httpclient.HTTPClient(username=USERNAME, password=PASSWORD,
tenant_id=TENANT_ID, auth_url=AUTH_URL) tenant_id=TENANT_ID, auth_url=AUTH_URL)
keyring_key = cl._build_keyring_key(auth_url=AUTH_URL, keyring_key = cl._build_keyring_key(auth_url=AUTH_URL,
@@ -86,7 +86,7 @@ class KeyringTest(utils.TestCase):
(AUTH_URL, TENANT_ID, TENANT, TOKEN, USERNAME)) (AUTH_URL, TENANT_ID, TENANT, TOKEN, USERNAME))
def test_set_and_get_keyring_expired(self): def test_set_and_get_keyring_expired(self):
cl = client.HTTPClient(username=USERNAME, password=PASSWORD, cl = httpclient.HTTPClient(username=USERNAME, password=PASSWORD,
tenant_id=TENANT_ID, auth_url=AUTH_URL, tenant_id=TENANT_ID, auth_url=AUTH_URL,
use_keyring=True) use_keyring=True)
keyring_key = cl._build_keyring_key(auth_url=AUTH_URL, keyring_key = cl._build_keyring_key(auth_url=AUTH_URL,
@@ -108,7 +108,7 @@ class KeyringTest(utils.TestCase):
self.assertIsNone(auth_ref) self.assertIsNone(auth_ref)
def test_set_and_get_keyring(self): def test_set_and_get_keyring(self):
cl = client.HTTPClient(username=USERNAME, password=PASSWORD, cl = httpclient.HTTPClient(username=USERNAME, password=PASSWORD,
tenant_id=TENANT_ID, auth_url=AUTH_URL, tenant_id=TENANT_ID, auth_url=AUTH_URL,
use_keyring=True) use_keyring=True)
keyring_key = cl._build_keyring_key(auth_url=AUTH_URL, keyring_key = cl._build_keyring_key(auth_url=AUTH_URL,

View File

@@ -5,7 +5,7 @@ import sys
from testtools import matchers from testtools import matchers
from keystoneclient import client from keystoneclient import httpclient
from tests import utils from tests import utils
from tests.v2_0 import fakes from tests.v2_0 import fakes
@@ -28,11 +28,11 @@ class ShellTests(utils.TestCase):
self.fake_client = fakes.FakeHTTPClient() self.fake_client = fakes.FakeHTTPClient()
self.stubs.Set( self.stubs.Set(
client.HTTPClient, "_cs_request", httpclient.HTTPClient, "_cs_request",
lambda ign_self, *args, **kwargs: lambda ign_self, *args, **kwargs:
self.fake_client._cs_request(*args, **kwargs)) self.fake_client._cs_request(*args, **kwargs))
self.stubs.Set( self.stubs.Set(
client.HTTPClient, "authenticate", httpclient.HTTPClient, "authenticate",
lambda cl_obj: lambda cl_obj:
self.fake_client.authenticate(cl_obj)) self.fake_client.authenticate(cl_obj))
self.old_environment = os.environ.copy() self.old_environment = os.environ.copy()