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 <mbasti@redhat.com>
This commit is contained in:
Stanislav Laznicka 2016-05-13 15:13:21 +02:00 committed by Martin Basti
parent 8b7f2500ba
commit 72f5c52d8c

View File

@ -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)