Pass all adapter parameters through to adapter
We can't simply pass through kwargs to the adapter for compatibility reasons however make sure that we accept the appropriate arguments and pass them to adapter. Also add some notes to try and keep them up to date. Closes-Bug: #1399492 Change-Id: If72295590483bb52fcf5a0d59cf95f3e49ea69c8
This commit is contained in:
@@ -47,6 +47,8 @@ class Adapter(object):
|
||||
interface=None, region_name=None, endpoint_override=None,
|
||||
version=None, auth=None, user_agent=None,
|
||||
connect_retries=None):
|
||||
# NOTE(jamielennox): when adding new parameters to adapter please also
|
||||
# add them to the adapter call in httpclient.HTTPClient.__init__
|
||||
self.session = session
|
||||
self.service_type = service_type
|
||||
self.service_name = service_name
|
||||
|
@@ -185,7 +185,20 @@ class HTTPClient(baseclient.Client, base.BaseAuthPlugin):
|
||||
:param object session: A Session object to be used for
|
||||
communicating with the identity service.
|
||||
:type session: keystoneclient.session.Session
|
||||
|
||||
:param string service_name: The default service_name for URL discovery.
|
||||
default: None (optional)
|
||||
:param string interface: The default interface for URL discovery.
|
||||
default: admin (optional)
|
||||
:param string endpoint_override: Always use this endpoint URL for requests
|
||||
for this client. (optional)
|
||||
:param auth: An auth plugin to use instead of the session one. (optional)
|
||||
:type auth: keystoneclient.auth.base.BaseAuthPlugin
|
||||
:param string user_agent: The User-Agent string to set.
|
||||
default: python-keystoneclient (optional)
|
||||
:param int connect_retries: the maximum number of retries that should
|
||||
be attempted for connection errors.
|
||||
Default None - use session default which
|
||||
is don't retry. (optional)
|
||||
"""
|
||||
|
||||
version = None
|
||||
@@ -198,7 +211,9 @@ class HTTPClient(baseclient.Client, base.BaseAuthPlugin):
|
||||
user_domain_id=None, user_domain_name=None, domain_id=None,
|
||||
domain_name=None, project_id=None, project_name=None,
|
||||
project_domain_id=None, project_domain_name=None,
|
||||
trust_id=None, session=None, **kwargs):
|
||||
trust_id=None, session=None, service_name=None,
|
||||
interface='admin', endpoint_override=None, auth=None,
|
||||
user_agent=USER_AGENT, connect_retries=None, **kwargs):
|
||||
# set baseline defaults
|
||||
self.user_id = None
|
||||
self.username = None
|
||||
@@ -305,11 +320,19 @@ class HTTPClient(baseclient.Client, base.BaseAuthPlugin):
|
||||
self.domain = ''
|
||||
self.debug_log = debug
|
||||
|
||||
# NOTE(jamielennox): unfortunately we can't just use **kwargs here as
|
||||
# it would incompatibly limit the kwargs that can be passed to __init__
|
||||
# try and keep this list in sync with adapter.Adapter.__init__
|
||||
self._adapter = _KeystoneAdapter(session,
|
||||
service_type='identity',
|
||||
interface='admin',
|
||||
service_name=service_name,
|
||||
interface=interface,
|
||||
region_name=region_name,
|
||||
version=self.version)
|
||||
endpoint_override=endpoint_override,
|
||||
version=self.version,
|
||||
auth=auth,
|
||||
user_agent=user_agent,
|
||||
connect_retries=connect_retries)
|
||||
|
||||
# keyring setup
|
||||
if use_keyring and keyring is None:
|
||||
|
@@ -11,9 +11,14 @@
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import uuid
|
||||
|
||||
import six
|
||||
|
||||
from keystoneclient.auth import token_endpoint
|
||||
from keystoneclient import exceptions
|
||||
from keystoneclient import fixture
|
||||
from keystoneclient import session
|
||||
from keystoneclient.tests.v2_0 import client_fixtures
|
||||
from keystoneclient.tests.v2_0 import utils
|
||||
from keystoneclient.v2_0 import client
|
||||
@@ -151,3 +156,22 @@ class KeystoneClientTest(utils.TestCase):
|
||||
client.Client,
|
||||
tenant_name='exampleproject',
|
||||
auth_url=self.TEST_URL)
|
||||
|
||||
def test_client_params(self):
|
||||
opts = {'auth': token_endpoint.Token('a', 'b'),
|
||||
'connect_retries': 50,
|
||||
'endpoint_override': uuid.uuid4().hex,
|
||||
'interface': uuid.uuid4().hex,
|
||||
'region_name': uuid.uuid4().hex,
|
||||
'service_name': uuid.uuid4().hex,
|
||||
'user_agent': uuid.uuid4().hex,
|
||||
}
|
||||
|
||||
sess = session.Session()
|
||||
cl = client.Client(session=sess, **opts)
|
||||
|
||||
for k, v in six.iteritems(opts):
|
||||
self.assertEqual(v, getattr(cl._adapter, k))
|
||||
|
||||
self.assertEqual('identity', cl._adapter.service_type)
|
||||
self.assertEqual('v2.0', cl._adapter.version)
|
||||
|
@@ -12,8 +12,13 @@
|
||||
|
||||
import copy
|
||||
import json
|
||||
import uuid
|
||||
|
||||
import six
|
||||
|
||||
from keystoneclient.auth import token_endpoint
|
||||
from keystoneclient import exceptions
|
||||
from keystoneclient import session
|
||||
from keystoneclient.tests.v3 import client_fixtures
|
||||
from keystoneclient.tests.v3 import utils
|
||||
from keystoneclient.v3 import client
|
||||
@@ -196,3 +201,22 @@ class KeystoneClientTest(utils.TestCase):
|
||||
client.Client,
|
||||
project_name='exampleproject',
|
||||
auth_url=self.TEST_URL)
|
||||
|
||||
def test_client_params(self):
|
||||
opts = {'auth': token_endpoint.Token('a', 'b'),
|
||||
'connect_retries': 50,
|
||||
'endpoint_override': uuid.uuid4().hex,
|
||||
'interface': uuid.uuid4().hex,
|
||||
'region_name': uuid.uuid4().hex,
|
||||
'service_name': uuid.uuid4().hex,
|
||||
'user_agent': uuid.uuid4().hex,
|
||||
}
|
||||
|
||||
sess = session.Session()
|
||||
cl = client.Client(session=sess, **opts)
|
||||
|
||||
for k, v in six.iteritems(opts):
|
||||
self.assertEqual(v, getattr(cl._adapter, k))
|
||||
|
||||
self.assertEqual('identity', cl._adapter.service_type)
|
||||
self.assertEqual('v3', cl._adapter.version)
|
||||
|
Reference in New Issue
Block a user