summaryrefslogtreecommitdiffstats
path: root/install/tools/ipa-replica-manage
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2013-01-21 08:39:09 -0500
committerMartin Kosek <mkosek@redhat.com>2013-03-01 16:59:45 +0100
commit4779865ea30dba0b5f0594cdc4633b0cc93bf36a (patch)
tree17708b9facca822d26570de65cd691e12bf3eeff /install/tools/ipa-replica-manage
parentf5c404c65d81d9a28f171fabe7c5749d6c37f102 (diff)
downloadfreeipa-4779865ea30dba0b5f0594cdc4633b0cc93bf36a.tar.gz
freeipa-4779865ea30dba0b5f0594cdc4633b0cc93bf36a.tar.xz
freeipa-4779865ea30dba0b5f0594cdc4633b0cc93bf36a.zip
Replace getList by a get_entries method
The find_entries method is cumbersome to use: it requires keyword arguments for simple uses, and callers are tempted to ignore the 'truncated' flag it returns. Introduce a simpler method, get_entries, that returns the found list directly, and raises an errors if the list is truncated. Replace the getList method by get_entries. Part of the work for: https://fedorahosted.org/freeipa/ticket/2660
Diffstat (limited to 'install/tools/ipa-replica-manage')
-rwxr-xr-xinstall/tools/ipa-replica-manage22
1 files changed, 12 insertions, 10 deletions
diff --git a/install/tools/ipa-replica-manage b/install/tools/ipa-replica-manage
index 61b870873..58b7fa03d 100755
--- a/install/tools/ipa-replica-manage
+++ b/install/tools/ipa-replica-manage
@@ -156,7 +156,7 @@ def list_replicas(realm, host, replica, dirman_passwd, verbose):
dn = DN(('cn', 'masters'), ('cn', 'ipa'), ('cn', 'etc'), ipautil.realm_to_suffix(realm))
try:
- entries = conn.getList(dn, ldap.SCOPE_ONELEVEL)
+ entries = conn.get_entries(dn, ldap.SCOPE_ONELEVEL)
except:
print "Failed to read master data from '%s': %s" % (host, str(e))
return
@@ -166,7 +166,7 @@ def list_replicas(realm, host, replica, dirman_passwd, verbose):
dn = DN(('cn', 'replicas'), ('cn', 'ipa'), ('cn', 'etc'), ipautil.realm_to_suffix(realm))
try:
- entries = conn.getList(dn, ldap.SCOPE_ONELEVEL)
+ entries = conn.get_entries(dn, ldap.SCOPE_ONELEVEL)
except:
pass
else:
@@ -195,8 +195,9 @@ def list_replicas(realm, host, replica, dirman_passwd, verbose):
repl = replication.ReplicationManager(realm, winsync_peer,
dirman_passwd)
cn, dn = repl.agreement_dn(replica)
- entries = repl.conn.getList(dn, ldap.SCOPE_BASE,
- "(objectclass=nsDSWindowsReplicationAgreement)")
+ entries = repl.conn.get_entries(
+ dn, ldap.SCOPE_BASE,
+ "(objectclass=nsDSWindowsReplicationAgreement)")
ent_type = 'winsync'
else:
repl = replication.ReplicationManager(realm, replica,
@@ -304,7 +305,7 @@ def del_link(realm, replica1, replica2, dirman_passwd, force=False):
try:
dn = DN(('cn', replica2), ('cn', 'replicas'), ('cn', 'ipa'), ('cn', 'etc'),
ipautil.realm_to_suffix(realm))
- entries = repl1.conn.getList(dn, ldap.SCOPE_SUBTREE)
+ entries = repl1.conn.get_entries(dn, ldap.SCOPE_SUBTREE)
if entries:
entries.sort(key=len, reverse=True)
for dn in entries:
@@ -455,7 +456,7 @@ def list_clean_ruv(realm, host, dirman_passwd, verbose):
repl = replication.ReplicationManager(realm, host, dirman_passwd)
dn = DN(('cn', 'cleanallruv'),('cn', 'tasks'), ('cn', 'config'))
try:
- entries = repl.conn.getList(dn, ldap.SCOPE_ONELEVEL)
+ entries = repl.conn.get_entries(dn, ldap.SCOPE_ONELEVEL)
except errors.NotFound:
print "No CLEANALLRUV tasks running"
else:
@@ -472,7 +473,7 @@ def list_clean_ruv(realm, host, dirman_passwd, verbose):
dn = DN(('cn', 'abort cleanallruv'),('cn', 'tasks'), ('cn', 'config'))
try:
- entries = repl.conn.getList(dn, ldap.SCOPE_ONELEVEL)
+ entries = repl.conn.get_entries(dn, ldap.SCOPE_ONELEVEL)
except errors.NotFound:
print "No abort CLEANALLRUV tasks running"
else:
@@ -586,7 +587,7 @@ def del_master(realm, hostname, options):
if force_del:
dn = DN(('cn', 'masters'), ('cn', 'ipa'), ('cn', 'etc'), thisrepl.suffix)
- entries = thisrepl.conn.getList(dn, ldap.SCOPE_ONELEVEL)
+ entries = thisrepl.conn.get_entries(dn, ldap.SCOPE_ONELEVEL)
replica_names = []
for entry in entries:
replica_names.append(entry.single_value('cn'))
@@ -616,7 +617,7 @@ def del_master(realm, hostname, options):
if delrepl and not winsync:
masters_dn = DN(('cn', 'masters'), ('cn', 'ipa'), ('cn', 'etc'), ipautil.realm_to_suffix(realm))
try:
- masters = delrepl.conn.getList(masters_dn, ldap.SCOPE_ONELEVEL)
+ masters = delrepl.conn.get_entries(masters_dn, ldap.SCOPE_ONELEVEL)
except Exception, e:
masters = []
print "Failed to read masters data from '%s': %s" % (delrepl.hostname, convert_error(e))
@@ -639,7 +640,8 @@ def del_master(realm, hostname, options):
for master_cn in [m.getValue('cn') for m in masters]:
master_dn = DN(('cn', master_cn), ('cn', 'masters'), ('cn', 'ipa'), ('cn', 'etc'), ipautil.realm_to_suffix(realm))
- services = delrepl.conn.getList(master_dn, ldap.SCOPE_ONELEVEL)
+ services = delrepl.conn.get_entries(master_dn,
+ delrepl.conn.SCOPE_ONELEVEL)
services_cns = [s.getValue('cn') for s in services]
if master_cn == hostname: