diff options
Diffstat (limited to 'ipa-admintools/ipa-adddelegation')
-rw-r--r-- | ipa-admintools/ipa-adddelegation | 52 |
1 files changed, 39 insertions, 13 deletions
diff --git a/ipa-admintools/ipa-adddelegation b/ipa-admintools/ipa-adddelegation index 53bd43ce2..62b4b96e8 100644 --- a/ipa-admintools/ipa-adddelegation +++ b/ipa-admintools/ipa-adddelegation @@ -23,9 +23,9 @@ from optparse import OptionParser import ipa import ipa.user import ipa.ipaclient as ipaclient -import ipa.ipavalidate as ipavalidate import ipa.config import ipa.aci +import ipa.ipaadminutil as ipaadminutil import xmlrpclib import kerberos @@ -68,27 +68,53 @@ def main(): client = ipaclient.IPAClient() source_grp = client.find_groups(options.source) - if source_grp[0] > 1: - print "Multiple matches found for %s." % options.source - return 2 - elif source_grp[0] == 0: - print "No matches found for %s." % options.source + counter = source_grp[0] + source_grp = source_grp[1:] + groupindex = -1 + if counter == 0: + print "No entries found for %s" % options.source return 2 + elif counter == -1: + print "These results are truncated." + print "Please refine your search and try again." + return 3 + + if counter > 1: + print "\nMultiple entries for the source group found." + groupindex = ipaadminutil.select_group(counter, source_grp) + if groupindex == "q": + return 0 + + if groupindex >= 0: + source_grp = [source_grp[groupindex]] target_grp = client.find_groups(options.target) - if target_grp[0] > 1: - print "Multiple matches found for %s." % options.target - return 3 - elif target_grp[0] == 0: - print "No matches found for %s." % options.target + counter = target_grp[0] + target_grp = target_grp[1:] + groupindex = -1 + if counter == 0: + print "No entries found for %s" % options.target + return 2 + elif counter == -1: + print "These results are truncated." + print "Please refine your search and try again." return 3 + if counter > 1: + print "\nMultiple entries for the target group found." + groupindex = ipaadminutil.select_group(counter, target_grp) + if groupindex == "q": + return 0 + + if groupindex >= 0: + target_grp = [target_grp[groupindex]] + attr_list = options.attributes.split(',') new_aci = ipa.aci.ACI() new_aci.name = args[1] - new_aci.source_group = source_grp[1].dn - new_aci.dest_group = target_grp[1].dn + new_aci.source_group = source_grp[0].dn + new_aci.dest_group = target_grp[0].dn new_aci.attrs = attr_list aci_entry = client.get_aci_entry(['*', 'aci']) |