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
This commit is contained in:
Ana Krivokapic 2013-08-29 17:44:02 +02:00 committed by Petr Viktorin
parent de7b1f86dc
commit 7959f3ee1e

View File

@ -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: