summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorRoman Rakus <rrakus@redhat.com>2012-09-21 14:19:59 +0200
committerRoman Rakus <rrakus@redhat.com>2012-09-21 14:19:59 +0200
commit029fdf1051c2992e4a08202589ddf3067bb512b9 (patch)
tree9c6a67353251b254cb9f0fd98a71c99f06c30bfc /examples
parent1285ef838782a6399606fc5af96e288236edf8e2 (diff)
downloadopenlmi-providers-029fdf1051c2992e4a08202589ddf3067bb512b9.tar.gz
openlmi-providers-029fdf1051c2992e4a08202589ddf3067bb512b9.tar.xz
openlmi-providers-029fdf1051c2992e4a08202589ddf3067bb512b9.zip
account: CreateGroup implemented
Signed-off-by: Roman Rakus <rrakus@redhat.com>
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/test_account.py41
1 files changed, 39 insertions, 2 deletions
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: