Skip to content

Commit

Permalink
enabled treated as string (bug 953678)
Browse files Browse the repository at this point in the history
Change-Id: I897797b3fb264647c486e6c10eab8edd00eadbcc
  • Loading branch information
dolph committed Mar 14, 2012
1 parent 8c824bd commit 5c223fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions keystoneclient/utils.py
Expand Up @@ -91,4 +91,7 @@ def isunauthenticated(f):


def string_to_bool(arg):
if isinstance(arg, bool):
return arg

return arg.strip().lower() in ('t', 'true', 'yes', '1')
8 changes: 4 additions & 4 deletions keystoneclient/v2_0/shell.py
Expand Up @@ -42,7 +42,8 @@ def do_user_list(kc, args):
def do_user_create(kc, args):
"""Create new user"""
user = kc.users.create(args.name, args.passwd, args.email,
tenant_id=args.tenant_id, enabled=args.enabled)
tenant_id=args.tenant_id,
enabled=utils.string_to_bool(args.enabled))
utils.print_dict(user._info)


Expand Down Expand Up @@ -111,7 +112,7 @@ def do_tenant_create(kc, args):
"""Create new tenant"""
tenant = kc.tenants.create(args.name,
description=args.description,
enabled=args.enabled)
enabled=utils.string_to_bool(args.enabled))
utils.print_dict(tenant._info)


Expand All @@ -131,8 +132,7 @@ def do_tenant_update(kc, args):
if args.description:
kwargs.update({'description': args.description})
if args.enabled:
new_enable = args.enabled.lower() in ['true', 'yes', '1']
kwargs.update({'enabled': new_enable})
kwargs.update({'enabled': utils.string_to_bool(args.enabled)})

if kwargs == {}:
print "Tenant not updated, no arguments present."
Expand Down

0 comments on commit 5c223fb

Please sign in to comment.