summaryrefslogtreecommitdiffstats
path: root/ipa-admintools/ipa-addgroup
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2008-05-30 10:19:08 -0400
committerRob Crittenden <rcritten@redhat.com>2008-05-30 11:23:07 -0400
commit32800a792b721d1bbe0d54b9a282e76419a4a037 (patch)
tree7a4af6b8b43c401f85afa8e0e12eb224dcd83616 /ipa-admintools/ipa-addgroup
parentee2b83210bc4446b0f5846fa0fb95822f5a3ece6 (diff)
downloadfreeipa-32800a792b721d1bbe0d54b9a282e76419a4a037.tar.gz
freeipa-32800a792b721d1bbe0d54b9a282e76419a4a037.tar.xz
freeipa-32800a792b721d1bbe0d54b9a282e76419a4a037.zip
Add two now options, --addattr and --setattr, to allow arbitrary attributes to be added and set when a new user or group is created.
Make the user password not mandatory and add new option, -P, to prompt for a password interactively. 449006
Diffstat (limited to 'ipa-admintools/ipa-addgroup')
-rw-r--r--ipa-admintools/ipa-addgroup34
1 files changed, 33 insertions, 1 deletions
diff --git a/ipa-admintools/ipa-addgroup b/ipa-admintools/ipa-addgroup
index fea84287c..89f763006 100644
--- a/ipa-admintools/ipa-addgroup
+++ b/ipa-admintools/ipa-addgroup
@@ -43,9 +43,12 @@ error was:
sys.exit(1)
def usage():
- print "ipa-addgroup [-d|--description STRING] [-g|--gid GID] [-v|--verbose] group"
+ print "ipa-addgroup [-d|--description STRING] [-g|--gid GID] [--addattr attribute=value] [--setattr attribute=value] [-v|--verbose] group"
sys.exit(1)
+def set_add_usage(which):
+ print "%s option usage: --%s NAME=VALUE" % (which, which)
+
def parse_options():
parser = OptionParser()
parser.add_option("-d", "--description", dest="desc",
@@ -54,6 +57,12 @@ def parse_options():
help="The gid to use for this group. If not included one is automatically set.")
parser.add_option("-v", "--verbose", action="store_true", dest="verbose",
help="Verbose output of the XML-RPC connection")
+ parser.add_option("--addattr", dest="addattr",
+ help="Adds an attribute or values to that attribute, attr=value",
+ action="append")
+ parser.add_option("--setattr", dest="setattr",
+ help="Set an attribute, dropping any existing values that may exist",
+ action="append")
parser.add_option("--usage", action="store_true",
help="Program usage")
@@ -107,6 +116,29 @@ def main():
group.setValue('cn', cn)
group.setValue('description', desc)
+ if options.setattr:
+ for s in options.setattr:
+ s = s.split('=')
+ if len(s) != 2:
+ set_add_usage("set")
+ sys.exit(1)
+ (attr,value) = s
+ group.setValue(attr, value)
+
+ if options.addattr:
+ for a in options.addattr:
+ a = a.split('=')
+ if len(a) != 2:
+ set_add_usage("add")
+ sys.exit(1)
+ (attr,value) = a
+ cvalue = group.getValue(attr)
+ if cvalue:
+ if isinstance(cvalue,str):
+ cvalue = [cvalue]
+ value = cvalue + [value]
+ group.setValue(attr, value)
+
client = ipaclient.IPAClient(verbose=options.verbose)
client.add_group(group)
print cn + " successfully added"