43
44
def do_user_list(kc, args):
45
46
users = kc.users.list(tenant_id=args.tenant_id)
46
utils.print_list(users, ['id', 'name', 'enabled', 'email'])
47
utils.print_list(users, ['id', 'name', 'enabled', 'email'],
49
51
@utils.arg('id', metavar='<user-id>', help='User ID to display')
108
110
kc.users.update_password(args.id, args.passwd)
113
@utils.arg('--current-password', metavar='<current-password>',
114
dest='currentpasswd', required=False, help='Current password, '
115
'Defaults to the password as set by --os-password or '
117
@utils.arg('--new-password ', metavar='<new-password>', dest='newpasswd',
118
required=False, help='Desired new password')
119
def do_password_update(kc, args):
120
"""Update own password"""
122
# we are prompting for these passwords if they are not passed in
123
# this gives users the option not to have their password
124
# appear in bash history etc..
125
currentpasswd = args.os_password
126
if args.currentpasswd is not None:
127
currentpasswd = args.currentpasswd
128
if currentpasswd is None:
129
currentpasswd = getpass.getpass('Current Password: ')
131
newpasswd = args.newpasswd
132
while newpasswd is None:
133
passwd1 = getpass.getpass('New Password: ')
134
passwd2 = getpass.getpass('Repeat New Password: ')
135
if passwd1 == passwd2:
138
kc.users.update_own_password(currentpasswd, newpasswd)
140
if args.os_password != newpasswd:
141
print "You should update the password you are using to authenticate "\
142
"to match your new password"
111
145
@utils.arg('id', metavar='<user-id>', help='User ID to delete')
112
146
def do_user_delete(kc, args):
113
147
"""Delete user"""
117
151
def do_tenant_list(kc, args):
118
152
"""List all tenants"""
119
153
tenants = kc.tenants.list()
120
utils.print_list(tenants, ['id', 'name', 'enabled'])
154
utils.print_list(tenants, ['id', 'name', 'enabled'], order_by='name')
123
157
@utils.arg('id', metavar='<tenant-id>', help='Tenant ID to display')
189
223
def do_service_list(kc, args):
190
224
"""List all services in Service Catalog"""
191
225
services = kc.services.list()
192
utils.print_list(services, ['id', 'name', 'type', 'description'])
226
utils.print_list(services, ['id', 'name', 'type', 'description'],
195
230
@utils.arg('id', metavar='<service-id>', help='Service ID to display')
208
243
def do_role_list(kc, args):
209
244
"""List all roles"""
210
245
roles = kc.roles.list()
211
utils.print_list(roles, ['id', 'name'])
246
utils.print_list(roles, ['id', 'name'], order_by='name')
214
249
@utils.arg('id', metavar='<role-id>', help='Role ID to display')
277
312
role.user_id = args.user_id
278
313
role.tenant_id = args.tenant_id
280
utils.print_list(roles, ['id', 'name', 'user_id', 'tenant_id'])
315
utils.print_list(roles, ['id', 'name', 'user_id', 'tenant_id'],
283
319
@utils.arg('--user-id', metavar='<user-id>', help='User ID')
285
321
@utils.arg('--tenant-id', metavar='<tenant-id>', help='Tenant ID')
286
322
@utils.arg('--tenant_id', help=argparse.SUPPRESS)
287
323
def do_ec2_credentials_create(kc, args):
288
"""Create EC2-compatibile credentials for user per tenant"""
324
"""Create EC2-compatible credentials for user per tenant"""
289
325
if not args.tenant_id:
290
326
# use the authenticated tenant id as a default
291
327
args.tenant_id = kc.auth_tenant_id
301
337
@utils.arg('--access', metavar='<access-key>', required=True,
302
338
help='Access Key')
303
339
def do_ec2_credentials_get(kc, args):
304
"""Display EC2-compatibile credentials"""
340
"""Display EC2-compatible credentials"""
305
341
if not args.user_id:
306
342
# use the authenticated user id as a default
307
343
args.user_id = kc.auth_user_id
313
349
@utils.arg('--user-id', metavar='<user-id>', help='User ID')
314
350
@utils.arg('--user_id', help=argparse.SUPPRESS)
315
351
def do_ec2_credentials_list(kc, args):
316
"""List EC2-compatibile credentials for a user"""
352
"""List EC2-compatible credentials for a user"""
317
353
if not args.user_id:
318
354
# use the authenticated user id as a default
319
355
args.user_id = kc.auth_user_id
333
369
@utils.arg('--access', metavar='<access-key>', required=True,
334
370
help='Access Key')
335
371
def do_ec2_credentials_delete(kc, args):
336
"""Delete EC2-compatibile credentials"""
372
"""Delete EC2-compatible credentials"""
337
373
if not args.user_id:
338
374
# use the authenticated user id as a default
339
375
args.user_id = kc.auth_user_id