From 95d3d3d60b9e981bcd192ed11242d58873fd09bf Mon Sep 17 00:00:00 2001 From: Ana Krivokapic Date: Thu, 29 Aug 2013 17:44:02 +0200 Subject: 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(-) (limited to 'install') diff --git a/install/tools/ipa-server-install b/install/tools/ipa-server-install index bfdef82a..1bf932da 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: -- cgit