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

Bug #1511417 reported by Thiago Paiva Brito
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python-novaclient
Fix Released
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
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-novaclient (master)

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
Revision history for this message
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'.

Revision history for this message
Thiago Paiva Brito (outbrito) 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)
Changed in python-novaclient:
importance: Undecided → Wishlist
assignee: Ed Leafe (ed-leafe) → Thiago Paiva Brito (thiagop)
Pavel Kholkin (pkholkin)
Changed in python-novaclient:
assignee: Thiago Paiva Brito (thiagop) → Pavel Kholkin (pkholkin)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-novaclient (master)

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
Revision history for this message
Thierry Carrez (ttx) wrote : Fix included in openstack/python-novaclient 6.0.0

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

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

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  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.