diff options
author | Rob Crittenden <rcritten@redhat.com> | 2012-01-16 10:24:15 -0500 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2012-01-30 17:27:55 +0100 |
commit | 7a1399bee1547b85186e010720a90ed6ab2f5e22 (patch) | |
tree | 0f3043f5b7a8d6d92767a6e0729624db3b7cde58 /install/tools/ipa-csreplica-manage | |
parent | ce360f37f884f76512c3d806819267a214352970 (diff) | |
download | freeipa-7a1399bee1547b85186e010720a90ed6ab2f5e22.tar.gz freeipa-7a1399bee1547b85186e010720a90ed6ab2f5e22.tar.xz freeipa-7a1399bee1547b85186e010720a90ed6ab2f5e22.zip |
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
Diffstat (limited to 'install/tools/ipa-csreplica-manage')
-rwxr-xr-x | install/tools/ipa-csreplica-manage | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/install/tools/ipa-csreplica-manage b/install/tools/ipa-csreplica-manage index ac39b70fa..97c504552 100755 --- a/install/tools/ipa-csreplica-manage +++ b/install/tools/ipa-csreplica-manage @@ -267,12 +267,26 @@ def del_link(realm, replica1, replica2, dirman_passwd, force=False): repl1.delete_agreement(replica2) repl1.delete_referral(replica2) + print "Deleted replication agreement from '%s' to '%s'" % (replica1, replica2) + def del_master(realm, hostname, options): force_del = False delrepl = None - # 1. Connect to the dogtag DS to be removed. + + # 1. Connect to the local dogtag DS server + try: + thisrepl = CSReplicationManager(realm, options.host, + options.dirman_passwd) + except Exception, e: + sys.exit("Failed to connect to server %s: %s" % (options.host, convert_error(e))) + + # 2. Ensure we have an agreement with the master + if thisrepl.get_replication_agreement(hostname) is None: + sys.exit("'%s' has no replication agreement for '%s'" % (options.host, hostname)) + + # 3. Connect to the dogtag DS to be removed. try: delrepl = CSReplicationManager(realm, hostname, options.dirman_passwd) except Exception, e: @@ -283,21 +297,14 @@ def del_master(realm, hostname, options): print "Unable to connect to replica %s, forcing removal" % hostname force_del = True - # 2. Connect to the local dogtag DS server - try: - thisrepl = CSReplicationManager(realm, options.host, - options.dirman_passwd) - except Exception, e: - sys.exit("Failed to connect to server %s: %s" % (options.host, convert_error(e))) - - # 2. Get list of agreements. + # 4. Get list of agreements. if delrepl is None: # server not up, just remove it from this server replica_names = [options.host] else: replica_names = delrepl.find_ipa_replication_agreements() - # 3. Remove each agreement + # 5. Remove each agreement for r in replica_names: try: del_link(realm, r, hostname, options.dirman_passwd, force=True) |