check whether replica exists before executing the domain level 1 deletion code

Move this check before the parts that check topology suffix connectivity, wait
for removed segments etc. If the hostname does not exist, it should really be
one of the first errors user encounters during ipa-replica-manage del.

https://fedorahosted.org/freeipa/ticket/5424

Reviewed-By: Martin Basti <mbasti@redhat.com>
Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
This commit is contained in:
Martin Babinsky authored and Martin Basti committed 2015-12-04 23:09:50 +01:00
1 parent 0997f6b9aa
commit ee853a3d35
1 file changed
+11 -7
+11 -7
View File
@@ -668,6 +668,16 @@ def del_master_managed(realm, hostname, options):
print("Can't remove itself: %s" % (options.host))
sys.exit(1)
try:
api.Command.server_show(hostname_u)
except errors.NotFound:
if not options.cleanup:
print("{hostname} is not listed among IPA masters.".format(
hostname=hostname))
print("Please specify an actual server or add the --cleanup "
"option to force clean up.")
sys.exit(1)
# 1. Connect to the local server
try:
thisrepl = replication.ReplicationManager(realm, options.host,
@@ -702,13 +712,7 @@ def del_master_managed(realm, hostname, options):
try:
api.Command.server_del(hostname_u)
except errors.NotFound:
if not options.cleanup:
print("{hostname} does not exist.".format(hostname=hostname))
print("Please specify an actual server or add the --cleanup "
"option to force clean up.")
sys.exit(1)
else:
print("Server entry already deleted: %s" % (hostname))
print("Server entry already deleted: %s" % (hostname))
# 6. Cleanup
try: