On 03/07/15 06:17, David Kupka wrote:
Since ipa-replica-* tools will be soon removed I think this simple check
should be enough.



Updated patch attached.

--
David Kupka
From 3df59261538f6b28e158802d8f6e4a47dadeab84 Mon Sep 17 00:00:00 2001
From: David Kupka <dku...@redhat.com>
Date: Fri, 3 Jul 2015 05:59:55 +0200
Subject: [PATCH] ipa-replica-prepare: Do not create DNS zone it automatically.

When --ip-address is specified check if relevant DNS zone exists
in IPA managed DNS server, exit with error when not.

https://fedorahosted.org/freeipa/ticket/5014
---
 ipaserver/install/ipa_replica_prepare.py | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/ipaserver/install/ipa_replica_prepare.py b/ipaserver/install/ipa_replica_prepare.py
index 46ac886e5a0f86574531861159d955bd149648c4..5246f5f5469c85571d04c99d872f38018802abaa 100644
--- a/ipaserver/install/ipa_replica_prepare.py
+++ b/ipaserver/install/ipa_replica_prepare.py
@@ -264,6 +264,14 @@ class ReplicaPrepare(admintool.AdminTool):
             options.reverse_zones = bindinstance.check_reverse_zones(
                 options.ip_addresses, options.reverse_zones, options, False,
                 True)
+
+            host, zone = self.replica_fqdn.split('.', 1)
+            if not bindinstance.dns_zone_exists(zone, api=api):
+                self.log.error("DNS zone %s does not exist in IPA managed DNS "
+                               "server. Either create DNS zone or omit "
+                               "--ip-address option." % zone)
+                raise admintool.ScriptError("Cannot add DNS record")
+
             if disconnect:
                 api.Backend.ldap2.disconnect()
 
@@ -481,11 +489,6 @@ class ReplicaPrepare(admintool.AdminTool):
             api.Backend.ldap2.connect(
                 bind_dn=DN(('cn', 'Directory Manager')),
                 bind_pw=self.dirman_password)
-        try:
-            add_zone(domain)
-        except errors.PublicError, e:
-            raise admintool.ScriptError(
-                "Could not create master DNS zone for the replica: %s" % e)
 
         for reverse_zone in options.reverse_zones:
             self.log.info("Adding reverse zone %s", reverse_zone)
-- 
2.4.3

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to