From 72f5c52d8cca32d8de5e8e0228d8ad3246efda48 Mon Sep 17 00:00:00 2001 From: Stanislav Laznicka Date: Fri, 13 May 2016 15:13:21 +0200 Subject: [PATCH] fixes premature sys.exit in ipa-replica-manage del Deletion of a replica would fail should there be no RUVs on the server. Also removed some dead code in del_master_managed which might cause premature exit if RuntimeError occurs. https://fedorahosted.org/freeipa/ticket/5307 Reviewed-By: Martin Basti --- install/tools/ipa-replica-manage | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/install/tools/ipa-replica-manage b/install/tools/ipa-replica-manage index 9f6cfa6ca..df0edb3b2 100755 --- a/install/tools/ipa-replica-manage +++ b/install/tools/ipa-replica-manage @@ -465,9 +465,12 @@ def get_rid_by_host(realm, sourcehost, host, dirman_passwd, nolookup=False): """ try: servers = get_ruv(realm, sourcehost, dirman_passwd, nolookup) - except (NoRUVsFound, RuntimeError) as e: + except RuntimeError as e: print(e) - sys.exit(0 if isinstance(e, NoRUVsFound) else 1) + sys.exit(1) + except NoRUVsFound as e: + print(e) + servers = [] for (netloc, rid) in servers: if '%s:389' % host == netloc: return int(rid) @@ -963,10 +966,6 @@ def del_master_managed(realm, hostname, options): # And pick new CA master. ensure_last_services(api.Backend.ldap2, hostname, masters, options) - # Save the RID value before we start deleting - rid = get_rid_by_host(realm, options.host, hostname, - options.dirman_passwd, options.nolookup) - # 5. Remove master entry. Topology plugin will remove replication agreements. try: api.Command.server_del(hostname_u)