On 09/03/2013 08:25 AM, Martin Kosek wrote:
> On 09/02/2013 06:21 PM, Tomas Babej wrote:
>> On 09/02/2013 06:07 PM, Petr Viktorin wrote:
>>> On 08/29/2013 05:56 PM, Ana Krivokapic wrote:
>>>> Hello,
>>>>
>>>> This patch addresses ticket https://fedorahosted.org/freeipa/ticket/3867.
>>>>
>>> Patch works well.
>>> It's temping to restart the discussion about how to wrap text output from
>>> installation tools. Wrapping at 60 characters because it looks better in the
>>> code seems suboptimal.
>>> Does anyone remember if we established some guideline last time this came 
>>> up?
>>>
>>>
>> I'm not sure if I'm missing something, but do we need a guideline here?
>>
>> I don't see any reason why not have best of the both worlds, using print as a
>> function we can wrap the text inside the parenthesis
>> with no effect on the output whatsoever. Or use print statement, but enclose
>> the text in parenthesis. Or use backslash.
>>
> Yes. But whatever we choose, we need to make sure that the resulting text is
> wrapped the same to avoid inconsistent output.
>
> IMO we should do our best to keep the text wrapped at 80 characters in new or
> updated texts. So I would prefer to have Ana's patch refactored a bit, to
> change wrapping of the resulting from 60 to 80 characters.
>
> Martin

Text is wrapped at 80 characters in the updated patch.

-- 
Regards,

Ana Krivokapic
Associate Software Engineer
FreeIPA team
Red Hat Inc.

From b47a751de3279de38e13a2b626c7ea003c0175a5 Mon Sep 17 00:00:00 2001
From: Ana Krivokapic <akriv...@redhat.com>
Date: Thu, 29 Aug 2013 17:44:02 +0200
Subject: [PATCH] Add warning when uninstalling active replica

Add a warning when trying to uninstall a replica that has active replication
agreements.

https://fedorahosted.org/freeipa/ticket/3867
---
 install/tools/ipa-server-install | 36 +++++++++++++++++++++++++++++++-----
 1 file changed, 31 insertions(+), 5 deletions(-)

diff --git a/install/tools/ipa-server-install b/install/tools/ipa-server-install
index bfdef82ab7be1dd76efcab2514cda73445b483a9..1bf932da731965b342c0c49d39e6a175bf98705b 100755
--- a/install/tools/ipa-server-install
+++ b/install/tools/ipa-server-install
@@ -28,18 +28,17 @@
 
 import sys
 import os
-import errno
 import grp
-import subprocess
 import signal
 import shutil
-import glob
 import pickle
 import random
 import tempfile
 import nss.error
 import base64
-from optparse import OptionGroup, OptionValueError, SUPPRESS_HELP
+import pwd
+import textwrap
+from optparse import OptionGroup, OptionValueError
 
 from ipaserver.install import dsinstance
 from ipaserver.install import krbinstance
@@ -51,10 +50,11 @@ from ipaserver.install import cainstance
 from ipaserver.install import memcacheinstance
 from ipaserver.install import otpdinstance
 from ipaserver.install import sysupgrade
-
+from ipaserver.install import replication
 from ipaserver.install import service, installutils
 from ipapython import version
 from ipapython import certmonger
+from ipapython import ipaldap
 from ipaserver.install.installutils import *
 from ipaserver.plugins.ldap2 import ldap2
 
@@ -624,6 +624,32 @@ def main():
                 print "Aborting uninstall operation."
                 sys.exit(1)
 
+        conn = ipaldap.IPAdmin(api.env.host, ldapi=True, realm=api.env.realm)
+        conn.do_external_bind(pwd.getpwuid(os.geteuid()).pw_name)
+        rm = replication.ReplicationManager(api.env.realm, api.env.host, None,
+                                            conn=conn)
+        agreements = rm.find_ipa_replication_agreements()
+
+        if agreements:
+            other_masters = [a.get('cn')[0][4:] for a in agreements]
+            msg = (
+                "\nReplication agreements with the following IPA masters "
+                "found: %s. Removing any replication agreements before "
+                "uninstalling the server is strongly recommended. You can "
+                "remove replication agreements by running the following "
+                "command on any other IPA master:\n" % ", ".join(other_masters)
+            )
+            cmd = "$ ipa-replica-manage del %s\n" % api.env.host
+            print textwrap.fill(msg, width=80, replace_whitespace=False)
+            print cmd
+            if not (options.unattended or user_input("Are you sure you want "
+                                                     "to continue with the "
+                                                     "uninstall procedure?",
+                                                     False)):
+                print ""
+                print "Aborting uninstall operation."
+                sys.exit(1)
+
         return uninstall()
 
     if options.external_ca:
-- 
1.8.3.1

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to