From bf29b44942160b30eb9ed347bf5b6c8f30418d6e Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Mon, 16 Jan 2012 10:24:15 -0500 Subject: Check for the existence of a replication agreement before deleting it. When using ipa-replica-manage or ipa-csreplica-manage to delete an agreement with a host we would try to make a connection to that host prior to tryign to delete it. This meant that the trying to delete a host we don't have an agreement with would return a connection error instead of a "no agreement with host foo" error. Also display a completed message when an agreement is removed. https://fedorahosted.org/freeipa/ticket/2048 https://fedorahosted.org/freeipa/ticket/2125 --- ipaserver/install/replication.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'ipaserver') diff --git a/ipaserver/install/replication.py b/ipaserver/install/replication.py index 052f1834..6f637251 100644 --- a/ipaserver/install/replication.py +++ b/ipaserver/install/replication.py @@ -211,6 +211,28 @@ class ReplicationManager(object): return res + def get_replication_agreement(self, hostname): + """ + The replication agreements are stored in + cn="$SUFFIX",cn=mapping tree,cn=config + + Get the replication agreement for a specific host. + + Returns None if not found. + """ + + filt = "(&(objectclass=nsds5ReplicationAgreement)(nsDS5ReplicaHost=%s))" % hostname + try: + entry = self.conn.search_s("cn=mapping tree,cn=config", + ldap.SCOPE_SUBTREE, filt) + except ldap.NO_SUCH_OBJECT: + return None + + if len(entry) == 0: + return None + else: + return entry[0] # There can be only one + def add_replication_manager(self, conn, dn, pw): """ Create a pseudo user to use for replication. -- cgit