Improve some error handling in ipa-replica-manage

If you break a replica install after the agreement is created but
before it gets much further you'll be in the situation where an
agreement exists, no cn=masters entry exists, and the RUV may not
be set yet.

This adds some error handling so the broken install can be safely
removed.

https://fedorahosted.org/freeipa/ticket/3444
This commit is contained in:
Rob Crittenden 2013-03-01 17:45:41 -05:00
parent 66356f0daf
commit c8846bab25

View File

@ -654,8 +654,11 @@ def del_master(realm, hostname, options):
for master_cn in [m.single_value('cn') for m in masters]: for master_cn in [m.single_value('cn') for m in masters]:
master_dn = DN(('cn', master_cn), ('cn', 'masters'), ('cn', 'ipa'), ('cn', 'etc'), ipautil.realm_to_suffix(realm)) master_dn = DN(('cn', master_cn), ('cn', 'masters'), ('cn', 'ipa'), ('cn', 'etc'), ipautil.realm_to_suffix(realm))
services = delrepl.conn.get_entries(master_dn, try:
delrepl.conn.SCOPE_ONELEVEL) services = delrepl.conn.get_entries(master_dn,
delrepl.conn.SCOPE_ONELEVEL)
except errors.NotFound:
continue
services_cns = [s.single_value('cn') for s in services] services_cns = [s.single_value('cn') for s in services]
if master_cn == hostname: if master_cn == hostname:
@ -690,7 +693,7 @@ def del_master(realm, hostname, options):
"from %s: %s" % (hostname, r, e)) "from %s: %s" % (hostname, r, e))
# 5. Clean RUV for the deleted master # 5. Clean RUV for the deleted master
if repltype == replication.IPA_REPLICA: if repltype == replication.IPA_REPLICA and rid is not None:
try: try:
thisrepl.cleanallruv(rid) thisrepl.cleanallruv(rid)
except KeyboardInterrupt: except KeyboardInterrupt: