From 2a72b86cd11605808a936024cf7093e01cf1d46e Mon Sep 17 00:00:00 2001 From: Andrey Kurilin Date: Fri, 15 Apr 2016 12:31:26 +0300 Subject: [PATCH] Restrict positional arguments for Client It is hard to deprecate or remove arguments for Client objects. We already have several args which are not used anywhere and we need to do something with them(clean code). Change-Id: I2218ff0c750922a105d21a13e42f193ffd86ec01 --- novaclient/client.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/novaclient/client.py b/novaclient/client.py index 5fa7060dd..f2143d685 100644 --- a/novaclient/client.py +++ b/novaclient/client.py @@ -809,7 +809,8 @@ def get_client_class(version): return client_class -def Client(version, *args, **kwargs): +def Client(version, username=None, api_key=None, project_id=None, + auth_url=None, *args, **kwargs): """Initialize client object based on given version. HOW-TO: @@ -830,7 +831,15 @@ def Client(version, *args, **kwargs): session API. See "The novaclient Python API" page at python-novaclient's doc. """ + if args: + warnings.warn("Only VERSION, USERNAME, PASSWORD, PROJECT_ID and " + "AUTH_URL arguments can be specified as positional " + "arguments. All other variables should be keyword " + "arguments. Note that this will become an error in " + "Ocata.") api_version, client_class = _get_client_class_and_version(version) kwargs.pop("direct_use", None) - return client_class(api_version=api_version, direct_use=False, + return client_class(username=username, api_key=api_key, + project_id=project_id, auth_url=auth_url, + api_version=api_version, direct_use=False, *args, **kwargs)