Rename api_key to password
"password" term is more clear. Resolves FIXME from the code: FIXME(comstud): Rename the api_key argument above when we know it's not being used as keyword argument Change-Id: I39f810a181b119591cf017eded71356a437a8c0a
This commit is contained in:
parent
1ce917ef25
commit
f98b8470de
@ -850,7 +850,7 @@ def _check_arguments(kwargs, release, deprecated_name, right_name=None):
|
||||
warnings.warn(msg)
|
||||
|
||||
|
||||
def Client(version, username=None, api_key=None, project_id=None,
|
||||
def Client(version, username=None, password=None, project_id=None,
|
||||
auth_url=None, **kwargs):
|
||||
"""Initialize client object based on given version.
|
||||
|
||||
@ -872,19 +872,24 @@ def Client(version, username=None, api_key=None, project_id=None,
|
||||
session API. See "The novaclient Python API" page at
|
||||
python-novaclient's doc.
|
||||
"""
|
||||
|
||||
if password:
|
||||
kwargs["password"] = password
|
||||
_check_arguments(kwargs, "Ocata", "auth_plugin")
|
||||
_check_arguments(kwargs, "Ocata", "auth_system")
|
||||
if "no_cache" in kwargs:
|
||||
_check_arguments(kwargs, "Ocata", "no_cache", "os_cache")
|
||||
_check_arguments(kwargs, "Ocata", "no_cache", right_name="os_cache")
|
||||
# os_cache is not a fully compatible with no_cache, so we need to
|
||||
# apply this custom processing
|
||||
kwargs["os_cache"] = not kwargs["os_cache"]
|
||||
_check_arguments(kwargs, "Ocata", "bypass_url", "endpoint_override")
|
||||
_check_arguments(kwargs, "Ocata", "bypass_url",
|
||||
right_name="endpoint_override")
|
||||
_check_arguments(kwargs, "Ocata", "api_key", right_name="password")
|
||||
|
||||
api_version, client_class = _get_client_class_and_version(version)
|
||||
kwargs.pop("direct_use", None)
|
||||
return client_class(username=username, api_key=api_key,
|
||||
project_id=project_id, auth_url=auth_url,
|
||||
api_version=api_version, direct_use=False,
|
||||
return client_class(api_version=api_version,
|
||||
auth_url=auth_url,
|
||||
direct_use=False,
|
||||
project_id=project_id,
|
||||
username=username,
|
||||
**kwargs)
|
||||
|
@ -56,7 +56,7 @@ class V1(fixtures.Fixture):
|
||||
|
||||
def new_client(self):
|
||||
return client.Client("2", username='xx',
|
||||
api_key='xx',
|
||||
password='xx',
|
||||
project_id='xx',
|
||||
auth_url=self.identity_url)
|
||||
|
||||
|
@ -211,12 +211,6 @@ class ClientTest(utils.TestCase):
|
||||
self.assertTrue(fake_client.open_session.called)
|
||||
self.assertTrue(fake_client.close_session.called)
|
||||
|
||||
def test_client_with_password_in_args_and_kwargs(self):
|
||||
# check that TypeError is not raised during instantiation of Client
|
||||
cs = novaclient.client.Client("2", "user", "password", "project_id",
|
||||
password='pass')
|
||||
self.assertEqual('pass', cs.client.password)
|
||||
|
||||
def test_get_password_simple(self):
|
||||
cs = novaclient.client.HTTPClient("user", "password", "", "")
|
||||
cs.password_func = mock.Mock()
|
||||
|
@ -68,7 +68,7 @@ class Client(object):
|
||||
directly. It should be done via `novaclient.client.Client` interface.
|
||||
"""
|
||||
|
||||
def __init__(self, api_key=None,
|
||||
def __init__(self,
|
||||
api_version=None,
|
||||
auth=None,
|
||||
auth_token=None,
|
||||
@ -83,6 +83,7 @@ class Client(object):
|
||||
insecure=False,
|
||||
logger=None,
|
||||
os_cache=False,
|
||||
password=None,
|
||||
project_id=None,
|
||||
proxy_tenant_id=None,
|
||||
proxy_token=None,
|
||||
@ -99,7 +100,6 @@ class Client(object):
|
||||
**kwargs):
|
||||
"""Initialization of Client object.
|
||||
|
||||
:param str api_key: API Key
|
||||
:param api_version: Compute API version
|
||||
:type api_version: novaclient.api_versions.APIVersion
|
||||
:param str auth: Auth
|
||||
@ -115,6 +115,7 @@ class Client(object):
|
||||
:param bool insecure: Allow insecure
|
||||
:param logging.Logger logger: Logger instance to be used for all
|
||||
logging stuff
|
||||
:param str password: User password
|
||||
:param bool os_cache: OS cache
|
||||
:param str project_id: Project ID
|
||||
:param str proxy_tenant_id: Tenant ID
|
||||
@ -138,16 +139,12 @@ class Client(object):
|
||||
"'novaclient.client.Client' instead. Related lp "
|
||||
"bug-report: 1493576"))
|
||||
|
||||
# FIXME(comstud): Rename the api_key argument above when we
|
||||
# know it's not being used as keyword argument
|
||||
|
||||
# NOTE(cyeoh): In the novaclient context (unlike Nova) the
|
||||
# project_id is not the same as the tenant_id. Here project_id
|
||||
# is a name (what the Nova API often refers to as a project or
|
||||
# tenant name) and tenant_id is a UUID (what the Nova API
|
||||
# often refers to as a project_id or tenant_id).
|
||||
|
||||
password = kwargs.pop('password', api_key)
|
||||
self.projectid = project_id
|
||||
self.tenant_id = tenant_id
|
||||
self.user_id = user_id
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
deprecations:
|
||||
- The **api_key** variable of novaclient.client.Client entry-point was
|
||||
deprecated in favor of **password**. Nothing has changed in the case
|
||||
of positional argument usage.
|
Loading…
Reference in New Issue
Block a user