From 029fdf1051c2992e4a08202589ddf3067bb512b9 Mon Sep 17 00:00:00 2001 From: Roman Rakus Date: Fri, 21 Sep 2012 14:19:59 +0200 Subject: account: CreateGroup implemented Signed-off-by: Roman Rakus --- examples/test_account.py | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/test_account.py b/examples/test_account.py index d35da78..143a3c4 100755 --- a/examples/test_account.py +++ b/examples/test_account.py @@ -14,8 +14,8 @@ Available commands and their parameters: delete_user - delete account, needed parameter is account name delete_group - delete group, needed parameter is group name delete_identity - delete user or group, parameter InstanceID of identity - create_account - creates a new account, parameters: - [0] = Name: required, user login name + create_account - creates a new account, parameter required, user login name + create_group - creates a new group, parameter required, group name Example: %s https://127.0.0.1:5989 root redhat list_user""" % (sys.argv[0], sys.argv[0]) @@ -112,6 +112,43 @@ elif command == "create_account": Name = parameters[0], System = computerSystems[0].path) +elif command == "create_group": +# create a new group +# Firstly find system name, which is necessary parameter for method +# then invoke the method + if not parameters: + usage() + sys.exit(1) + + computerSystems = cliconn.ExecQuery('WQL', 'select * from Linux_ComputerSystem') + if not computerSystems: + print >>sys.stderr, "No usable Linux_ComputerSystem instance found." + sys.exit(2) + + if len(computerSystems) > 1: + print >>sys.stderr, "More than one Linux_ComputerSystem instance found, don't know which to use." + sys.exit(3) + + lams = cliconn.ExecQuery('WQL', 'select * from LMI_AccountManagementService')[0] + + print cliconn.InvokeMethod("CreateGroup", lams.path, + Name = parameters[0], + System = computerSystems[0].path) + +elif command == "delete_user": +# Find user by given name and call DeleteInstance on the instance path + 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] + elif command == "delete_user": # Find user by given name and call DeleteInstance on the instance path if not parameters: -- cgit