From c6f1a3dcdcb0b0fb8e7d52c954b0b1c72d7acdf9 Mon Sep 17 00:00:00 2001 From: Roman Rakus Date: Fri, 21 Sep 2012 09:22:42 +0200 Subject: account: delete_user example Signed-off-by: Roman Rakus --- examples/test_account.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'examples') diff --git a/examples/test_account.py b/examples/test_account.py index f36cc7a..e3bca25 100755 --- a/examples/test_account.py +++ b/examples/test_account.py @@ -11,6 +11,7 @@ Available commands and their parameters: list_user - list users, parameter is user name or empty for all 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 create_account - creates a new account, parameters: [0] = Name: required, user login name @@ -109,6 +110,21 @@ elif command == "create_account": Name = parameters[0], 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 + if not parameters: + usage() + sys.exit(1) + + slct = 'select * from LMI_Account where Name = "%s"' % parameters[0] + + instances = cliconn.ExecQuery('WQL', slct) + if instances: + print cliconn.DeleteInstance(instances[0].path) + else: + print >> sys.stderr, "User does not exist: %s" %parameters[0] + else: # unknown command print "Unknown command", command -- cgit