403b09
From 90b827a6d23d864bfac96d2ff0f89f1a3ba1d245 Mon Sep 17 00:00:00 2001
403b09
From: Stanislav Laznicka <slaznick@redhat.com>
403b09
Date: Fri, 12 Aug 2016 11:59:41 +0200
403b09
Subject: [PATCH] Fail on topology disconnect/last role removal
403b09
403b09
Disconnecting topology/removing last-role-host during server
403b09
uninstallation should raise error rather than just being logged
403b09
if the appropriate ignore settings are not present.
403b09
403b09
https://fedorahosted.org/freeipa/ticket/6168
403b09
403b09
Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
403b09
---
403b09
 ipaserver/install/server/install.py | 6 ++++--
403b09
 1 file changed, 4 insertions(+), 2 deletions(-)
403b09
403b09
diff --git a/ipaserver/install/server/install.py b/ipaserver/install/server/install.py
403b09
index 94698898934844350488d5fc52d6e1e567624502..86b8402750b503ea7dacd1f4c59c82d9bd4082e6 100644
403b09
--- a/ipaserver/install/server/install.py
403b09
+++ b/ipaserver/install/server/install.py
403b09
@@ -25,6 +25,7 @@ from ipapython.ipa_log_manager import root_logger
403b09
 from ipapython.ipautil import (
403b09
     decrypt_file, format_netloc, ipa_generate_password, run, user_input,
403b09
     is_fips_enabled)
403b09
+from ipapython.admintool import ScriptError
403b09
 from ipaplatform import services
403b09
 from ipaplatform.paths import paths
403b09
 from ipaplatform.tasks import tasks
403b09
@@ -294,7 +295,6 @@ def common_cleanup(func):
403b09
 def remove_master_from_managed_topology(api_instance, options):
403b09
     try:
403b09
         # we may force the removal
403b09
-        # if the master was already deleted we will just get a warning
403b09
         server_del_options = dict(
403b09
             force=True,
403b09
             ignore_topology_disconnect=options.ignore_topology_disconnect,
403b09
@@ -303,8 +303,10 @@ def remove_master_from_managed_topology(api_instance, options):
403b09
 
403b09
         replication.run_server_del_as_cli(
403b09
             api_instance, api_instance.env.host, **server_del_options)
403b09
-
403b09
+    except errors.ServerRemovalError as e:
403b09
+        raise ScriptError(str(e))
403b09
     except Exception as e:
403b09
+        # if the master was already deleted we will just get a warning
403b09
         root_logger.warning("Failed to delete master: {}".format(e))
403b09
 
403b09
 
403b09
-- 
403b09
2.9.3
403b09