From 7faa01fbaed22c074afeab82c4de811f29d6e8d2 Mon Sep 17 00:00:00 2001 From: Roman Rakus Date: Fri, 21 Sep 2012 12:05:20 +0200 Subject: account: DeleteInstance of LMI_Identity Signed-off-by: Roman Rakus --- examples/test_account.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/test_account.py b/examples/test_account.py index e3bca25..519a2f2 100755 --- a/examples/test_account.py +++ b/examples/test_account.py @@ -12,6 +12,7 @@ Available commands and their parameters: list_group - list groups, parameter is group name or empty for all group_members - list members of group, parameter is group name delete_user - delete account, needed parameter is account name + delete_identity - delete user or group, parameter InstanceID of identity create_account - creates a new account, parameters: [0] = Name: required, user login name @@ -111,8 +112,7 @@ elif command == "create_account": System = computerSystems[0].path) elif command == "delete_user": -# Listintg users is simple, just query all instances from LMI_Account -# or select only by given Name +# Find user by given name and call DeleteInstance on the instance path if not parameters: usage() sys.exit(1) @@ -125,6 +125,24 @@ elif command == "delete_user": else: print >> sys.stderr, "User does not exist: %s" %parameters[0] +elif command == "delete_identity": +# Have to pass correct InstanceID +# It is in format: +# LMI:UID:user_id +# or +# LMI:GID:group_id + if not parameters: + usage() + sys.exit(1) + + slct = 'select * from LMI_Identity where InstanceID = "%s"' % parameters[0] + + instances = cliconn.ExecQuery('WQL', slct) + if instances: + print cliconn.DeleteInstance(instances[0].path) + else: + print >> sys.stderr, "Identity does not exist: %s" %parameters[0] + else: # unknown command print "Unknown command", command -- cgit