diff options
| author | Dolph Mathews <dolph.mathews@gmail.com> | 2012-03-09 09:59:34 -0600 |
|---|---|---|
| committer | Dolph Mathews <dolph.mathews@gmail.com> | 2012-03-09 13:23:38 -0600 |
| commit | 93d07cc793ad710d8456ccb732e155ee504ca780 (patch) | |
| tree | d69d01ab9a43e2bc647ea37ef2b7264c872f1da8 /keystoneclient/v2_0/shell.py | |
| parent | 6ce6ebbc96ff5892c39aba2a91e660c300d0f512 (diff) | |
| download | python-keystoneclient-93d07cc793ad710d8456ccb732e155ee504ca780.tar.gz | |
List roles for user on CLI (bug 932282)
Change-Id: I947d2ff74b0a131e4ecc7d696877aea4d994fe71
Diffstat (limited to 'keystoneclient/v2_0/shell.py')
| -rwxr-xr-x | keystoneclient/v2_0/shell.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/keystoneclient/v2_0/shell.py b/keystoneclient/v2_0/shell.py index 91d0b23..b045780 100755 --- a/keystoneclient/v2_0/shell.py +++ b/keystoneclient/v2_0/shell.py @@ -180,9 +180,21 @@ def do_service_delete(kc, args): kc.services.delete(args.id) +@utils.arg('--user', metavar='<user-id>', + help='List roles granted to a user') +@utils.arg('--tenant_id', metavar='<tenant-id>', + help='List roles granted on a tenant') def do_role_list(kc, args): - """List all available roles""" - roles = kc.roles.list() + """List all roles, or only those granted to a user.""" + if bool(args.tenant_id) ^ bool(args.user): + print 'User ID and Tenant ID are both required to list granted roles.' + return + + if args.tenant_id and args.user: + roles = kc.roles.roles_for_user(user=args.user, tenant=args.tenant_id) + else: + roles = kc.roles.list() + utils.print_list(roles, ['id', 'name']) |
