diff options
author | Jan Cholasta <jcholast@redhat.com> | 2013-09-10 10:20:24 +0000 |
---|---|---|
committer | Petr Viktorin <pviktori@redhat.com> | 2013-11-05 13:56:55 +0100 |
commit | df5f4ee81d1aff1122dd92ab1b56eb335294c3a7 (patch) | |
tree | b112b429a896789029038bd3e25218495b647d56 /install/tools | |
parent | 989493979da3ef1136a9b346cace5689ef22eed8 (diff) | |
download | freeipa-df5f4ee81d1aff1122dd92ab1b56eb335294c3a7.tar.gz freeipa-df5f4ee81d1aff1122dd92ab1b56eb335294c3a7.tar.xz freeipa-df5f4ee81d1aff1122dd92ab1b56eb335294c3a7.zip |
Turn LDAPEntry.single_value into a dictionary-like property.
This change makes single_value consistent with the raw property.
https://fedorahosted.org/freeipa/ticket/3521
Diffstat (limited to 'install/tools')
-rwxr-xr-x | install/tools/ipa-csreplica-manage | 26 | ||||
-rwxr-xr-x | install/tools/ipa-managed-entries | 4 | ||||
-rwxr-xr-x | install/tools/ipa-replica-manage | 62 | ||||
-rwxr-xr-x | install/tools/ipactl | 4 |
4 files changed, 48 insertions, 48 deletions
diff --git a/install/tools/ipa-csreplica-manage b/install/tools/ipa-csreplica-manage index ce027be12..438a1b3ab 100755 --- a/install/tools/ipa-csreplica-manage +++ b/install/tools/ipa-csreplica-manage @@ -100,9 +100,9 @@ def list_replicas(realm, host, replica, dirman_passwd, verbose): try: cadn = DN(('cn', 'CA'), DN(ent.dn)) entry = conn.get_entry(cadn) - peers[ent.single_value('cn')] = ['master', ''] + peers[ent.single_value['cn']] = ['master', ''] except errors.NotFound: - peers[ent.single_value('cn')] = ['CA not configured', ''] + peers[ent.single_value['cn']] = ['CA not configured', ''] except Exception, e: sys.exit( @@ -124,19 +124,19 @@ def list_replicas(realm, host, replica, dirman_passwd, verbose): entries = repl.find_replication_agreements() for entry in entries: - print '%s' % entry.single_value('nsds5replicahost', None) + print '%s' % entry.single_value.get('nsds5replicahost') if verbose: - print " last init status: %s" % entry.single_value( - 'nsds5replicalastinitstatus', None) + print " last init status: %s" % entry.single_value.get( + 'nsds5replicalastinitstatus') print " last init ended: %s" % str( ipautil.parse_generalized_time( - entry.single_value('nsds5replicalastinitend'))) - print " last update status: %s" % entry.single_value( - 'nsds5replicalastupdatestatus', None) + entry.single_value['nsds5replicalastinitend'])) + print " last update status: %s" % entry.single_value.get( + 'nsds5replicalastupdatestatus') print " last update ended: %s" % str( ipautil.parse_generalized_time( - entry.single_value('nsds5replicalastupdateend'))) + entry.single_value['nsds5replicalastupdateend'])) def del_link(realm, replica1, replica2, dirman_passwd, force=False): @@ -152,7 +152,7 @@ def del_link(realm, replica1, replica2, dirman_passwd, force=False): # Find the DN of the replication agreement to remove replica1_dn = None for e in repl_list1: - if e.single_value('nsDS5ReplicaHost', None) == replica2: + if e.single_value.get('nsDS5ReplicaHost') == replica2: replica1_dn = e.dn break @@ -188,7 +188,7 @@ def del_link(realm, replica1, replica2, dirman_passwd, force=False): # Find the DN of the replication agreement to remove replica2_dn = None for e in repl_list: - if e.single_value('nsDS5ReplicaHost', None) == replica1: + if e.single_value.get('nsDS5ReplicaHost') == replica1: replica2_dn = e.dn break @@ -263,7 +263,7 @@ def del_master(realm, hostname, options): replica_names = [options.host] else: replica_entries = delrepl.find_ipa_replication_agreements() - replica_names = [rep.single_value('nsds5replicahost', None) + replica_names = [rep.single_value.get('nsds5replicahost') for rep in replica_entries] # 5. Remove each agreement @@ -311,7 +311,7 @@ def add_link(realm, replica1, replica2, dirman_passwd, options): dirman_passwd) entries = repl1.find_replication_agreements() for e in entries: - if e.single_value('nsDS5ReplicaHost', None) == replica2: + if e.single_value.get('nsDS5ReplicaHost') == replica2: sys.exit('This replication agreement already exists.') repl1.hostnames = [replica1, replica2] diff --git a/install/tools/ipa-managed-entries b/install/tools/ipa-managed-entries index 2cf37e203..f13497e12 100755 --- a/install/tools/ipa-managed-entries +++ b/install/tools/ipa-managed-entries @@ -113,7 +113,7 @@ def main(): except Exception, e: root_logger.debug("Search for managed entries failed: %s" % str(e)) sys.exit("Unable to find managed entries at %s" % managed_entry_definitions_dn) - managed_entries = [entry.single_value('cn') for entry in entries] + managed_entries = [entry.single_value['cn'] for entry in entries] if managed_entries: print "Available Managed Entry Definitions:" for managed_entry in managed_entries: @@ -132,7 +132,7 @@ def main(): filter, ['originfilter']) disable_attr = '(objectclass=disable)' try: - org_filter = entry.single_value('originfilter', None) + org_filter = entry.single_value.get('originfilter') disabled = re.search(r'%s' % disable_attr, org_filter) except KeyError: sys.exit("%s is not a valid Managed Entry" % def_dn) diff --git a/install/tools/ipa-replica-manage b/install/tools/ipa-replica-manage index 8e0948ec4..989a4ccaf 100755 --- a/install/tools/ipa-replica-manage +++ b/install/tools/ipa-replica-manage @@ -168,7 +168,7 @@ def list_replicas(realm, host, replica, dirman_passwd, verbose, nolookup=False): return else: for ent in entries: - peers[ent.single_value('cn')] = ['master', ''] + peers[ent.single_value['cn']] = ['master', ''] dn = DN(('cn', 'replicas'), ('cn', 'ipa'), ('cn', 'etc'), ipautil.realm_to_suffix(realm)) try: @@ -177,8 +177,8 @@ def list_replicas(realm, host, replica, dirman_passwd, verbose, nolookup=False): pass else: for ent in entries: - config_string = ent.single_value('ipaConfigString') - peers[ent.single_value('cn')] = config_string.split(':') + config_string = ent.single_value['ipaConfigString'] + peers[ent.single_value['cn']] = config_string.split(':') if not replica: for k, p in peers.iteritems(): @@ -215,18 +215,18 @@ def list_replicas(realm, host, replica, dirman_passwd, verbose, nolookup=False): return for entry in entries: - print '%s: %s' % (entry.single_value('nsds5replicahost', None), ent_type) + print '%s: %s' % (entry.single_value.get('nsds5replicahost'), ent_type) if verbose: - print " last init status: %s" % entry.single_value( - 'nsds5replicalastinitstatus', None) + print " last init status: %s" % entry.single_value.get( + 'nsds5replicalastinitstatus') print " last init ended: %s" % str(ipautil.parse_generalized_time( - entry.single_value('nsds5replicalastinitend'))) - print " last update status: %s" % entry.single_value( - 'nsds5replicalastupdatestatus', None) + entry.single_value['nsds5replicalastinitend'])) + print " last update status: %s" % entry.single_value.get( + 'nsds5replicalastupdatestatus') print " last update ended: %s" % str( ipautil.parse_generalized_time( - entry.single_value('nsds5replicalastupdateend'))) + entry.single_value['nsds5replicalastupdateend'])) def del_link(realm, replica1, replica2, dirman_passwd, force=False): """ @@ -480,12 +480,12 @@ def list_clean_ruv(realm, host, dirman_passwd, verbose, nolookup=False): else: print "CLEANALLRUV tasks" for entry in entries: - name = entry.single_value('cn').replace('clean ', '') - status = entry.single_value('nsTaskStatus', None) + name = entry.single_value['cn'].replace('clean ', '') + status = entry.single_value.get('nsTaskStatus') print "RID %s: %s" % (name, status) if verbose: print str(dn) - print entry.single_value('nstasklog', None) + print entry.single_value.get('nstasklog') print @@ -497,12 +497,12 @@ def list_clean_ruv(realm, host, dirman_passwd, verbose, nolookup=False): else: print "Abort CLEANALLRUV tasks" for entry in entries: - name = entry.single_value('cn').replace('abort ', '') - status = entry.single_value('nsTaskStatus', None) + name = entry.single_value['cn'].replace('abort ', '') + status = entry.single_value.get('nsTaskStatus') print "RID %s: %s" % (name, status) if verbose: print str(dn) - print entry.single_value('nstasklog', None) + print entry.single_value.get('nstasklog') def check_last_link(delrepl, realm, dirman_passwd, force): """ @@ -527,7 +527,7 @@ def check_last_link(delrepl, realm, dirman_passwd, force): """ replica_entries = delrepl.find_ipa_replication_agreements() - replica_names = [rep.single_value('nsds5replicahost', None) + replica_names = [rep.single_value.get('nsds5replicahost') for rep in replica_entries] orphaned = [] @@ -543,7 +543,7 @@ def check_last_link(delrepl, realm, dirman_passwd, force): continue entries = repl.find_ipa_replication_agreements() - names = [rep.single_value('nsds5replicahost', None) + names = [rep.single_value.get('nsds5replicahost') for rep in entries] if len(names) == 1 and names[0] == delrepl.hostname: @@ -614,7 +614,7 @@ def del_master(realm, hostname, options): dn, thisrepl.conn.SCOPE_ONELEVEL) replica_names = [] for entry in entries: - replica_names.append(entry.single_value('cn')) + replica_names.append(entry.single_value['cn']) # The host we're removing gets included in this list, remove it. # Otherwise we try to delete an agreement from the host to itself. try: @@ -624,7 +624,7 @@ def del_master(realm, hostname, options): else: # Get list of agreements. replica_entries = delrepl.find_ipa_replication_agreements() - replica_names = [rep.single_value('nsds5replicahost', None) + replica_names = [rep.single_value.get('nsds5replicahost') for rep in replica_entries] else: # WINSYNC replica, delete agreement from current host @@ -666,14 +666,14 @@ def del_master(realm, hostname, options): this_services = [] other_services = [] - for master_cn in [m.single_value('cn') for m in masters]: + for master_cn in [m.single_value['cn'] for m in masters]: master_dn = DN(('cn', master_cn), ('cn', 'masters'), ('cn', 'ipa'), ('cn', 'etc'), ipautil.realm_to_suffix(realm)) try: services = delrepl.conn.get_entries(master_dn, delrepl.conn.SCOPE_ONELEVEL) except errors.NotFound: continue - services_cns = [s.single_value('cn') for s in services] + services_cns = [s.single_value['cn'] for s in services] if master_cn == hostname: this_services = services_cns @@ -766,7 +766,7 @@ def add_link(realm, replica1, replica2, dirman_passwd, options): if repl.get_agreement_type(replica2) == replication.WINSYNC: agreement = repl.get_replication_agreement(replica2) sys.exit("winsync agreement already exists on subtree %s" % - agreement.single_value('nsds7WindowsReplicaSubtree', None)) + agreement.single_value.get('nsds7WindowsReplicaSubtree')) else: sys.exit("A replication agreement to %s already exists" % replica2) except errors.NotFound: @@ -864,7 +864,7 @@ def re_initialize(realm, thishost, fromhost, dirman_passwd, nolookup=False): # If the agreement doesn't have nsDS5ReplicatedAttributeListTotal it means # we did not replicate memberOf, do so now. - if not agreement.single_value('nsDS5ReplicatedAttributeListTotal', None): + if not agreement.single_value.get('nsDS5ReplicatedAttributeListTotal'): ds = dsinstance.DsInstance(realm_name = realm, dm_password = dirman_passwd) ds.ldapi = os.getegid() == 0 ds.init_memberof() @@ -918,7 +918,7 @@ def show_DNA_ranges(hostname, master, realm, dirman_passwd, nextrange=False, return False for ent in entries: - remote = ent.single_value('cn') + remote = ent.single_value['cn'] if master is not None and remote != master: continue try: @@ -974,7 +974,7 @@ def store_DNA_range(repl, range_start, range_max, deleted_master, realm, return False for ent in entries: - candidate = ent.single_value('cn') + candidate = ent.single_value['cn'] if candidate == deleted_master: continue try: @@ -1066,7 +1066,7 @@ def set_DNA_range(hostname, range, realm, dirman_passwd, next_range=False, sys.exit("Failed to read master data from '%s': %s" % (repl.conn.host, str(e))) else: for ent in entries: - master = ent.single_value('cn') + master = ent.single_value['cn'] if master == hostname and not next_range: continue try: @@ -1100,8 +1100,8 @@ def set_DNA_range(hostname, range, realm, dirman_passwd, next_range=False, sys.exit('Unable to load IPA ranges: %s' % e.message) for ent in entries: - entry_start = int(ent.single_value('ipabaseid')) - entry_max = entry_start + int(ent.single_value('ipaidrangesize')) + entry_start = int(ent.single_value['ipabaseid']) + entry_max = entry_start + int(ent.single_value['ipaidrangesize']) if dna_next >= entry_start and dna_max <= entry_max: break else: @@ -1115,8 +1115,8 @@ def set_DNA_range(hostname, range, realm, dirman_passwd, next_range=False, entries = [] for ent in entries: - entry_start = int(ent.single_value('ipabaseid')) - entry_max = entry_start + int(ent.single_value('ipaidrangesize')) + entry_start = int(ent.single_value['ipabaseid']) + entry_max = entry_start + int(ent.single_value['ipaidrangesize']) if range_intersection(dna_next, dna_max, entry_start, entry_max): sys.exit("New range overlaps with a Trust range. See ipa help idrange command") diff --git a/install/tools/ipactl b/install/tools/ipactl index df0d6f57e..2db0fde68 100755 --- a/install/tools/ipactl +++ b/install/tools/ipactl @@ -138,7 +138,7 @@ def get_config(dirsrv): masters_list.append("No master found because of error: %s" % str(e)) else: for dn, master_entry in entries: - masters_list.append(master_entry.single_value('cn')) + masters_list.append(master_entry.single_value['cn']) masters = "\n".join(masters_list) @@ -151,7 +151,7 @@ def get_config(dirsrv): svc_list = [] for entry in res: - name = entry.single_value('cn') + name = entry.single_value['cn'] for p in entry['ipaConfigString']: if p.startswith('startOrder '): order = p.split()[1] |