From 6a3ed312215a9c7bdc52663630629834ae5d8ddc Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Mon, 7 Dec 2009 23:03:08 -0500 Subject: Add force option to ipa-replica-manage to allow forcing deletion of a replica If a replica is not up for some reason (e.g. you've already deleted it) this used to quit and not let you delete the replica, generating errors in the DS logs. This will let you force a deletion. --- install/tools/ipa-replica-manage | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'install/tools/ipa-replica-manage') diff --git a/install/tools/ipa-replica-manage b/install/tools/ipa-replica-manage index f24b3f612..20d261c8f 100755 --- a/install/tools/ipa-replica-manage +++ b/install/tools/ipa-replica-manage @@ -36,6 +36,8 @@ def parse_options(): parser.add_option("-p", "--password", dest="dirman_passwd", help="Directory Manager password") parser.add_option("-v", "--verbose", dest="verbose", action="store_true", default=False, help="provide additional information") + parser.add_option("-f", "--force", dest="force", action="store_true", default=False, + help="ignore some types of errors") parser.add_option("--port", type="int", dest="port", help="port number of other server") parser.add_option("--binddn", dest="binddn", @@ -96,7 +98,7 @@ def list_masters(replman, verbose): print " last update status: %s" % entry.nsds5replicalastupdatestatus print " last update ended: %s" % str(ipautil.parse_generalized_time(entry.nsds5replicalastupdateend)) -def del_master(replman, hostname): +def del_master(replman, hostname, force=False): try: t = replman.get_agreement_type(hostname) except ldap.NO_SUCH_OBJECT: @@ -104,9 +106,15 @@ def del_master(replman, hostname): if t == replication.IPA_REPLICA: dirman_passwd = getpass.getpass("Directory Manager password (%s): " % hostname) - other_replman = replication.ReplicationManager(hostname, dirman_passwd) - other_replman.suffix = get_suffix() - other_replman.delete_agreement(replman.conn.host) + try: + other_replman = replication.ReplicationManager(hostname, dirman_passwd) + other_replman.suffix = get_suffix() + other_replman.delete_agreement(replman.conn.host) + except Exception, e: + if force: + print "Unable to remove agreement on %s: %s" % (hostname, str(e)) + else: + raise e replman.delete_agreement(hostname) @@ -190,7 +198,7 @@ def main(): if len(args) != 2: print "must provide hostname of master to delete" sys.exit(1) - del_master(r, args[1]) + del_master(r, args[1], options.force) elif args[0] == "add": if len(args) != 2: print "must provide hostname of master to add" -- cgit