On 12/04/2015 05:12 PM, Petr Vobornik wrote:
On 12/01/2015 09:18 AM, Martin Basti wrote:



On 18.11.2015 13:25, Martin Babinsky wrote:
Additional fix for https://fedorahosted.org/freeipa/ticket/5424

In current implementation the topology suffices are checked first and
after that the error about non-existent host is raised. This does not
make much sense to me, we should check for host existence before any
work is done.



ACK


Any reason to use host-show and not server-show?

host-show will be successful on any host, server-show only if the host
is an IPA server.
Good catch, I have fixed it in this patch. I have also modified the error message slightly.

--
Martin^3 Babinsky
From e4da5ca71d20ba7645f207bdfd31e09e83084517 Mon Sep 17 00:00:00 2001
From: Martin Babinsky <mbabi...@redhat.com>
Date: Wed, 18 Nov 2015 13:12:50 +0100
Subject: [PATCH] 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
---
 install/tools/ipa-replica-manage | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/install/tools/ipa-replica-manage b/install/tools/ipa-replica-manage
index 6d303e6f008325648461287448ef3d2712e23911..5124731255807287a7857b1a4cdc2e6799cd7278 100755
--- a/install/tools/ipa-replica-manage
+++ b/install/tools/ipa-replica-manage
@@ -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:
-- 
2.5.0

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to