Sort arguments for client's methods

We have a lot of arguments in several Clients methods. Reviewing their
changes is a hard task, so let's sort them to simplify reviews.

Change-Id: Ie78773fd92017fbc4631d0fc6ae9da2e15935537
This commit is contained in:
Andrey Kurilin 2016-12-02 18:38:06 +02:00 committed by Andrey Kurilin
parent f9d9a3d4dc
commit 330516543b
3 changed files with 107 additions and 70 deletions

View File

@ -680,18 +680,36 @@ class HTTPClient(object):
return self._extract_service_catalog(url, resp, respbody)
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',
extensions=None, service_type='compute',
service_name=None, volume_service_name=None,
timings=False, bypass_url=None, os_cache=False,
no_cache=True, http_log_debug=False,
auth_token=None, cacert=None, tenant_id=None,
user_id=None, connection_pool=False, session=None,
auth=None, user_agent='python-novaclient',
interface=None, api_version=None, **kwargs):
def _construct_http_client(api_version=None,
auth=None,
auth_token=None,
auth_url=None,
bypass_url=None,
cacert=None,
connection_pool=False,
endpoint_type='publicURL',
extensions=None,
http_log_debug=False,
insecure=False,
interface=None,
no_cache=True,
os_cache=False,
password=None,
project_id=None,
proxy_tenant_id=None,
proxy_token=None,
region_name=None,
service_name=None,
service_type='compute',
session=None,
tenant_id=None,
timeout=None,
timings=False,
user_agent='python-novaclient',
user_id=None,
username=None,
volume_service_name=None,
**kwargs):
# TODO(mordred): If not session, just make a Session, then return
# SessionClient always
if session:

View File

@ -57,8 +57,8 @@ FAKE_RESPONSE_HEADERS = {'x-openstack-request-id': FAKE_REQUEST_ID}
class FakeClient(fakes.FakeClient, client.Client):
def __init__(self, api_version, *args, **kwargs):
client.Client.__init__(self, 'username', 'password',
'project_id', 'auth_url',
client.Client.__init__(self, username='username', password='password',
project_id='project_id', auth_url='auth_url',
extensions=kwargs.get('extensions'),
direct_use=False, api_version=api_version)
self.client = FakeHTTPClient(api_version=api_version, **kwargs)
@ -2341,8 +2341,8 @@ class FakeHTTPClient(base_client.HTTPClient):
class FakeSessionClient(fakes.FakeClient, client.Client):
def __init__(self, api_version, *args, **kwargs):
client.Client.__init__(self, 'username', 'password',
'project_id', 'auth_url',
client.Client.__init__(self, username='username', password='password',
project_id='project_id', auth_url='auth_url',
extensions=kwargs.get('extensions'),
direct_use=False, api_version=api_version)
self.client = FakeSessionMockClient(api_version=api_version, **kwargs)

View File

@ -68,50 +68,69 @@ class Client(object):
directly. It should be done via `novaclient.client.Client` interface.
"""
def __init__(self, username=None, api_key=None, project_id=None,
auth_url=None, insecure=False, timeout=None,
proxy_tenant_id=None, proxy_token=None, region_name=None,
endpoint_type='publicURL', extensions=None,
service_type='compute', service_name=None,
volume_service_name=None, timings=False, bypass_url=None,
os_cache=False, no_cache=True, http_log_debug=False,
def __init__(self, api_key=None,
api_version=None,
auth=None,
auth_token=None,
cacert=None, tenant_id=None, user_id=None,
connection_pool=False, session=None, auth=None,
api_version=None, direct_use=True, logger=None, **kwargs):
auth_url=None,
bypass_url=None,
cacert=None,
connection_pool=False,
direct_use=True,
endpoint_type='publicURL',
extensions=None,
http_log_debug=False,
insecure=False,
logger=None,
no_cache=True,
os_cache=False,
project_id=None,
proxy_tenant_id=None,
proxy_token=None,
region_name=None,
service_name=None,
service_type='compute',
session=None,
tenant_id=None,
timeout=None,
timings=False,
user_id=None,
username=None,
volume_service_name=None,
**kwargs):
"""Initialization of Client object.
:param str username: Username
:param str api_key: API Key
:param str project_id: Project ID
:param api_version: Compute API version
:type api_version: novaclient.api_versions.APIVersion
:param str auth: Auth
:param str auth_token: Auth token
:param str auth_url: Auth URL
:param str bypass_url: Bypass URL
:param str cacert: cacert
:param bool direct_use: Inner variable of novaclient. Do not use it
outside novaclient. It's restricted.
:param str endpoint_type: Endpoint Type
:param str extensions: Extensions
:param bool http_log_debug: Enable debugging for HTTP connections
:param bool insecure: Allow insecure
:param float timeout: API timeout, None or 0 disables
:param logging.Logger logger: Logger instance to be used for all
logging stuff
:param bool no_cache: No cache
:param bool os_cache: OS cache
:param str project_id: Project ID
:param str proxy_tenant_id: Tenant ID
:param str proxy_token: Proxy Token
:param str region_name: Region Name
:param str endpoint_type: Endpoint Type
:param str extensions: Extensions
:param str service_type: Service Type
:param str service_name: Service Name
:param str volume_service_name: Volume Service Name
:param bool timings: Timings
:param str bypass_url: Bypass URL
:param bool os_cache: OS cache
:param bool no_cache: No cache
:param bool http_log_debug: Enable debugging for HTTP connections
:param str auth_token: Auth token
:param str cacert: cacert
:param str tenant_id: Tenant ID
:param str user_id: User ID
:param bool connection_pool: Use a connection pool
:param str service_type: Service Type
:param str session: Session
:param str auth: Auth
:param api_version: Compute API version
:param direct_use: Inner variable of novaclient. Do not use it outside
novaclient. It's restricted.
:param logger: Logger
:type api_version: novaclient.api_versions.APIVersion
:param str tenant_id: Tenant ID
:param float timeout: API timeout, None or 0 disables
:param bool timings: Timings
:param str user_id: User ID
:param str username: Username
:param str volume_service_name: Volume Service Name
"""
if direct_use:
raise exceptions.Forbidden(
@ -210,32 +229,32 @@ class Client(object):
extension.manager_class(self))
self.client = client._construct_http_client(
username=username,
password=password,
user_id=user_id,
project_id=project_id,
tenant_id=tenant_id,
auth_url=auth_url,
api_version=api_version,
auth=auth,
auth_token=auth_token,
insecure=insecure,
timeout=timeout,
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,
volume_service_name=volume_service_name,
timings=timings,
auth_url=auth_url,
bypass_url=bypass_url,
os_cache=self.os_cache,
http_log_debug=http_log_debug,
cacert=cacert,
connection_pool=connection_pool,
session=session,
auth=auth,
api_version=api_version,
endpoint_type=endpoint_type,
http_log_debug=http_log_debug,
insecure=insecure,
logger=self.logger,
os_cache=self.os_cache,
password=password,
project_id=project_id,
proxy_tenant_id=proxy_tenant_id,
proxy_token=proxy_token,
region_name=region_name,
service_name=service_name,
service_type=service_type,
session=session,
tenant_id=tenant_id,
timeout=timeout,
timings=timings,
user_id=user_id,
username=username,
volume_service_name=volume_service_name,
**kwargs)
@property