"role assignment list" fails if two users in different domains have the same name

Bug #1472909 reported by Benoît Knecht
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python-openstackclient
Fix Released
High
Lin Hua Cheng

Bug Description

Using Identity API v3, with a user called "username" in the "default" domain, and a user called "username" in the "admin" domain, the following command fails:

(openstack) role assignment list --user username
INFO: openstackclient.shell command: role assignment list -> openstackclient.identity.v3.role_assignment.ListRoleAssignment
DEBUG: openstackclient.identity.v3.role_assignment.ListRoleAssignment take_action(Namespace(columns=[], domain=None, effective=False, formatter='table', group=None, max_width=0, project=None, quote_mode='nonnumeric', role=None, user='username'))
DEBUG: keystoneclient.session REQ: curl -g -i -X GET https://openstack.example.com:35357/v3/users?name=username -H "User-Agent: python-keystoneclient" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}3ccfd4004fb1b6c698457ee3c74f8c177cde51b4"
DEBUG: requests.packages.urllib3.connectionpool "GET /v3/users?name=username HTTP/1.1" 200 663
DEBUG: keystoneclient.session RESP: [200] date: Thu, 09 Jul 2015 06:08:20 GMT vary: X-Auth-Token content-length: 663 content-type: application/json x-distribution: Ubuntu
RESP BODY: {"users": [{"name": "username", "links": {"self": "https://openstack.example.com:5000/v3/users/f3cf0a620733fd85456cdf8c50e1d9e9"}, "domain_id": "default", "enabled": true, "email": "<email address hidden>", "id": "f3cf0a620733fd85456cdf8c50e1d9e9"}, {"name": "username", "links": {"self": "https://openstack.example.com:5000/v3/users/76667091c17e533febe58b8cea318a38"}, "domain_id": "4015bc9ee91e437d90df83fb64fbbe31", "enabled": true, "email": "<email address hidden>", "id": "76667091c17e533febe58b8cea318a38"}], "links": {"self": "https://openstack.example.com:5000/v3/users?name=username", "previous": null, "next": null}}

ERROR: openstack More than one user exists with the name 'username'.
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/cliff/app.py", line 314, in run_subcommand
    result = cmd.run(parsed_args)
  File "/usr/lib/python2.7/site-packages/cliff/display.py", line 92, in run
    column_names, data = self.take_action(parsed_args)
  File "/usr/lib/python2.7/site-packages/openstackclient/identity/v3/role_assignment.py", line 86, in take_action
    parsed_args.user,
  File "/usr/lib/python2.7/site-packages/openstackclient/identity/common.py", line 73, in find_user
    users.User, domain_id=domain_id)
  File "/usr/lib/python2.7/site-packages/openstackclient/identity/common.py", line 105, in _find_identity_resource
    name_or_id, **kwargs)
  File "/usr/lib/python2.7/site-packages/openstackclient/common/utils.py", line 96, in find_resource
    raise exceptions.CommandError(msg)
CommandError: More than one user exists with the name 'username'.
DEBUG: openstackclient.shell clean_up ListRoleAssignment: More than one user exists with the name 'username'.
More than one user exists with the name 'username'.

I would have expected that command to list the role assignments of the users called "username" in all the domains. But even when trying to restrict the search to a specific domain, the command fails:

(openstack) role assignment list --domain admin --user username
INFO: openstackclient.shell command: role assignment list -> openstackclient.identity.v3.role_assignment.ListRoleAssignment
DEBUG: openstackclient.identity.v3.role_assignment.ListRoleAssignment take_action(Namespace(columns=[], domain='admin', effective=False, formatter='table', group=None, max_width=0, project=None, quote_mode='nonnumeric', role=None, user='username'))
DEBUG: keystoneclient.session REQ: curl -g -i -X GET https://openstack.example.com:35357/v3/users?name=username -H "User-Agent: python-keystoneclient" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}951a86ffc52c1cb4b9be7a374ad404e3151e04b3"
INFO: requests.packages.urllib3.connectionpool Resetting dropped connection: openstack.example.com
DEBUG: requests.packages.urllib3.connectionpool "GET /v3/users?name=username HTTP/1.1" 200 663
DEBUG: keystoneclient.session RESP: [200] date: Thu, 09 Jul 2015 04:55:51 GMT vary: X-Auth-Token content-length: 663 content-type: application/json x-distribution: Ubuntu
RESP BODY: {"users": [{"name": "username", "links": {"self": "https://openstack.example.com:5000/v3/users/f3cf0a620733fd85456cdf8c50e1d9e9"}, "domain_id": "default", "enabled": true, "email": "<email address hidden>", "id": "f3cf0a620733fd85456cdf8c50e1d9e9"}, {"name": "username", "links": {"self": "https://openstack.example.com:5000/v3/users/76667091c17e533febe58b8cea318a38"}, "domain_id": "4015bc9ee91e437d90df83fb64fbbe31", "enabled": true, "email": "<email address hidden>", "id": "76667091c17e533febe58b8cea318a38"}], "links": {"self": "https://openstack.example.com:5000/v3/users?name=username", "previous": null, "next": null}}

ERROR: openstack More than one user exists with the name 'username'.
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/cliff/app.py", line 314, in run_subcommand
    result = cmd.run(parsed_args)
  File "/usr/lib/python2.7/site-packages/cliff/display.py", line 92, in run
    column_names, data = self.take_action(parsed_args)
  File "/usr/lib/python2.7/site-packages/openstackclient/identity/v3/role_assignment.py", line 86, in take_action
    parsed_args.user,
  File "/usr/lib/python2.7/site-packages/openstackclient/identity/common.py", line 73, in find_user
    users.User, domain_id=domain_id)
  File "/usr/lib/python2.7/site-packages/openstackclient/identity/common.py", line 105, in _find_identity_resource
    name_or_id, **kwargs)
  File "/usr/lib/python2.7/site-packages/openstackclient/common/utils.py", line 96, in find_resource
    raise exceptions.CommandError(msg)
CommandError: More than one user exists with the name 'username'.
DEBUG: openstackclient.shell clean_up ListRoleAssignment: More than one user exists with the name 'username'.
More than one user exists with the name 'username'.

description: updated
description: updated
description: updated
heha (zhanghanqun)
Changed in python-openstackclient:
assignee: nobody → heha (zhanghanqun)
assignee: heha (zhanghanqun) → nobody
Changed in python-openstackclient:
status: New → Confirmed
assignee: nobody → Lin Hua Cheng (lin-hua-cheng)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-openstackclient (master)

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

Changed in python-openstackclient:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-openstackclient (master)

Reviewed: https://review.openstack.org/208109
Committed: https://git.openstack.org/cgit/openstack/python-openstackclient/commit/?id=701b59f651fe1ec88400f014165efa6b176f375c
Submitter: Jenkins
Branch: master

commit 701b59f651fe1ec88400f014165efa6b176f375c
Author: lin-hua-cheng <email address hidden>
Date: Fri Jul 31 18:56:34 2015 -0700

    Add domain scoping in 'role assignment list'

    Add ability to set which domain the user, group or project
    belong to.

    Change-Id: Idf6c7f23ab96261a73682226fb10ce5f0133924e
    Closes-Bug: #1472909

Changed in python-openstackclient:
status: In Progress → Fix Committed
Changed in python-openstackclient:
importance: Undecided → High
Changed in python-openstackclient:
milestone: none → 1.6.0
status: Fix Committed → Fix Released
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.