Named attribute 'password' to novaclient v2 breaks with "got multiple values for keyword argument 'password'"

Bug #1511417 reported by Thiago Paiva Brito on 2015-10-29
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python-novaclient
Wishlist
Pavel Kholkin

Bug Description

When instantiating novaclient with kwargs or named attributes, the 'password' field is duplicated due to an overwrite on the __init__ method of Client v2:

========================================================================================
from novaclient import client

kwargs = {
    'auth_url': 'http://my-keystone:5000/v2.0',
    'username': 'admin',
    'password': 'nomoresecrete',
    'tenant_name': 'admin'
}
nova = client.Client(2, **kwargs)

TypeError: _construct_http_client() got multiple values for keyword argument 'password'
========================================================================================
from novaclient import client

nova = client.Client(2,
                     auth_url='http://my-keystone:5000/v2.0',
                     username='admin',
                     password='nomoresecrete',
                     tenant_name='admin')

TypeError: _construct_http_client() got multiple values for keyword argument 'password'
========================================================================================

description: updated

Fix proposed to branch: master
Review: https://review.openstack.org/240277

Changed in python-novaclient:
assignee: nobody → Thiago Paiva Brito (thiagop)
status: New → In Progress
Kevin L. Mitchell (klmitch) wrote :

It looks to me like this bug is actually due to using the wrong parameter name; you're passing a 'password' parameter, but the parameter is actually named 'api_key'.

Thiago Paiva Brito (thiagop) wrote :

Hi Kevin, thanks for your comment. It is indeed strange that 'api_key' variable:

#1: 'api_key' becomes password here: https://github.com/openstack/python-novaclient/blob/f1ea28349bb8e3a79457137e4d06bb599b30b6c6/novaclient/v2/client.py#L123

#2: It is used to instantiate keystoneclient, that receives 'password' as argument

#3: Novaclient is the only client on openstack to call 'api_key' a variable that holds a password. I myself believe it is misleading.

#4: novaclient.client._construct_http_client receives 'password' as argument too.

That all leads me to conclude that 'api_key' must have being used for compatibility and shouldn't exclude the use of 'password'.

Changed in python-novaclient:
assignee: Thiago Paiva Brito (thiagop) → Ed Leafe (ed-leafe)
Matt Riedemann (mriedem) on 2016-03-10
Changed in python-novaclient:
importance: Undecided → Wishlist
assignee: Ed Leafe (ed-leafe) → Thiago Paiva Brito (thiagop)
Pavel Kholkin (pkholkin) on 2016-08-25
Changed in python-novaclient:
assignee: Thiago Paiva Brito (thiagop) → Pavel Kholkin (pkholkin)

Reviewed: https://review.openstack.org/240277
Committed: https://git.openstack.org/cgit/openstack/python-novaclient/commit/?id=f7dc91dc110f6526886ba9bb27215f6078c94455
Submitter: Jenkins
Branch: master

commit f7dc91dc110f6526886ba9bb27215f6078c94455
Author: Thiago Paiva <email address hidden>
Date: Thu Oct 29 12:45:48 2015 -0300

    Fixes TypeError on Client instantiation

    When instantiating novaclient with kwargs or named attributes, the 'password'
    field is duplicated due to an overwrite on the __init__ method of Client v2.
    This patch pops out the password field when it's passed and no api_key is
    provided.

    Co-Authored-By: Pavel Kholkin <email address hidden>

    Closes-bug: #1511417

    Change-Id: Id8310eccef5f0f9a2983e25dd35541d1eb0efe86

Changed in python-novaclient:
status: In Progress → Fix Released

This issue was fixed in the openstack/python-novaclient 6.0.0 release.

This issue was fixed in the openstack/python-novaclient 6.0.0 release.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers