user-get fails when using IDs which are not UUIDs

Bug #1189933 reported by Michael Solberg
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python-keystoneclient
Fix Released
High
Adam Young

Bug Description

When resolving the user positional argument to the "user-get" command, keystoneclient uses the following logic:

    # first try to get entity as integer id
    try:
        if isinstance(name_or_id, int) or name_or_id.isdigit():
            return manager.get(int(name_or_id))
    except exceptions.NotFound:
        pass

    # now try to get entity as uuid
    try:
        uuid.UUID(str(name_or_id))
        return manager.get(name_or_id)
    except (ValueError, exceptions.NotFound):
        pass

When using a readonly LDAP server as the identity store, userids are strings instead of integers or UUIDs. Thus user lookups fail with a exceptions.NotFound exception.

[root@virt-three keystone]# keystone user-list
+------------+--------------------+---------+---------------------------+
| id | name | enabled | email |
+------------+--------------------+---------+---------------------------+
| admin | Administrator | False | |
...
| rdo-admin | RDO Administrator | True | <email address hidden> |
+------------+--------------------+---------+---------------------------+
[root@virt-three keystone]# keystone user-get rdo-admin
No user with a name or ID of 'rdo-admin' exists.

The attached patch resolves this issue by adding a third search attempt with the userid cast as a string:

[root@virt-three keystone]# keystone user-get rdo-admin
+----------+---------------------------+
| Property | Value |
+----------+---------------------------+
| email | <email address hidden> |
| enabled | True |
| id | rdo-admin |
| name | RDO Administrator |
+----------+---------------------------+

Revision history for this message
Michael Solberg (msolberg) wrote :
Revision history for this message
Dolph Mathews (dolph) wrote :

Any chance you can put that patch up for review on gerrit?

Changed in python-keystoneclient:
status: New → Triaged
importance: Undecided → High
Revision history for this message
Dolph Mathews (dolph) wrote :

As of very recently, we also support a manager.find() method exactly for this.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-keystoneclient (master)

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

Changed in python-keystoneclient:
assignee: nobody → Michael Solberg (msolberg)
status: Triaged → In Progress
Revision history for this message
Michael Solberg (msolberg) wrote :

I've put my patch up on gerrit.

Changed in python-keystoneclient:
assignee: Michael Solberg (msolberg) → Adam Young (ayoung)
Changed in python-keystoneclient:
assignee: Adam Young (ayoung) → Michael Solberg (msolberg)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

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

Changed in python-keystoneclient:
assignee: Michael Solberg (msolberg) → Adam Young (ayoung)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-keystoneclient (master)

Reviewed: https://review.openstack.org/43939
Committed: http://github.com/openstack/python-keystoneclient/commit/1bd5b7328b2d25f88856912d25a89637996cceb5
Submitter: Jenkins
Branch: master

commit 1bd5b7328b2d25f88856912d25a89637996cceb5
Author: Michael Solberg <email address hidden>
Date: Tue Jun 11 12:00:14 2013 -0400

    remove the UUID check for userids

    Change-Id: I548d8ea292f737a6b5b0dddd8271a0cf690392a0
    Fixes: bug #1189933

Changed in python-keystoneclient:
status: In Progress → Fix Committed
Dolph Mathews (dolph)
Changed in python-keystoneclient:
milestone: none → 0.4.0
Dolph Mathews (dolph)
Changed in python-keystoneclient:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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