On Thursday 11 of July 2013 16:10:33 Ana Krivokapic wrote:
> On 07/11/2013 11:20 AM, Tomas Babej wrote:
> >          boolean_var = {}
> > -        for var in ('persistent_search', 'serial_autoincrement'):
> > +        for var in ('serial_autoincrement'):
> This won't work - a one element tuple needs a comma at the end:
> ('serial_autoincrement', )
> >              boolean_var[var] = "yes" if getattr(self, var, False) else "no"
> >  
> >          self.sub_dict = dict(FQDN=self.fqdn,
> > @@ -607,9 +604,8 @@ class BindInstance(service.Service):
> >                               SUFFIX=self.suffix,
> >                               OPTIONAL_NTP=optional_ntp,
> >                               ZONEMGR=self.zonemgr,
> > -                             ZONE_REFRESH=self.zone_refresh,
> >                               IPA_CA_RECORD=ipa_ca,
> > -                             
> > PERSISTENT_SEARCH=boolean_var['persistent_search'],
> > +                             PERSISTENT_SEARCH="yes",
> >                               
> > SERIAL_AUTOINCREMENT=boolean_var['serial_autoincrement'],)
> 
> But anyway, I think this piece of code is unnecessarily complicated, I don't 
> see
> a need for the 'boolean_var' dict here. I would suggest replacing it with
> something like:
> 
> serial_autoincrement = "yes" if self.serial_autoincrement else "no"
> 
> and then pass serial_autoincrement to self.sub_dict = dict(...)
> 
> 

Attached patch refactored the relevant part of the code.

Tomas
>From d56b32cb1961315bc1a23573ea7da843eaff36c2 Mon Sep 17 00:00:00 2001
From: Tomas Babej <tba...@redhat.com>
Date: Mon, 3 Jun 2013 14:37:20 +0200
Subject: [PATCH] Remove support for IPA deployments with no persistent search

Drops the code from ipa-server-install, ipa-dns-install and the
BindInstance itself. Also changed ipa-upgradeconfig script so
that it does not set zone_refresh to 0 on upgrades, as the option
is deprecated.

https://fedorahosted.org/freeipa/ticket/3632
---
 install/share/bind.named.conf.template |  1 -
 install/tools/ipa-dns-install          | 24 ---------------------
 install/tools/ipa-server-install       | 24 ---------------------
 install/tools/ipa-upgradeconfig        |  3 ++-
 install/tools/man/ipa-dns-install.1    |  6 ------
 install/tools/man/ipa-server-install.1 |  6 ------
 ipaserver/install/bindinstance.py      | 39 ++++++++++++++++------------------
 7 files changed, 20 insertions(+), 83 deletions(-)

diff --git a/install/share/bind.named.conf.template b/install/share/bind.named.conf.template
index e4ce6058399e8d9a1f112f55907e060075dff00b..f78e18b5fd1d44e4d75d8b412994f2810ede8d97 100644
--- a/install/share/bind.named.conf.template
+++ b/install/share/bind.named.conf.template
@@ -44,7 +44,6 @@ dynamic-db "ipa" {
 	arg "auth_method sasl";
 	arg "sasl_mech GSSAPI";
 	arg "sasl_user DNS/$FQDN";
-	arg "zone_refresh $ZONE_REFRESH";
 	arg "psearch $PERSISTENT_SEARCH";
 	arg "serial_autoincrement $SERIAL_AUTOINCREMENT";
 };
diff --git a/install/tools/ipa-dns-install b/install/tools/ipa-dns-install
index 47bc31b4786c32caf97f20de3cbf20bc767dfe1d..1119093042e987dfdf8fd734ebbf4b19bfd8600f 100755
--- a/install/tools/ipa-dns-install
+++ b/install/tools/ipa-dns-install
@@ -52,16 +52,6 @@ def parse_options():
     parser.add_option("--zonemgr", action="callback", callback=bindinstance.zonemgr_callback,
                       type="string",
                       help="DNS zone manager e-mail address. Defaults to hostmaster@DOMAIN")
-    # this option name has been deprecated, persistent search has been enabled by default
-    parser.add_option("--zone-notif", dest="zone_notif",
-                      action="store_true", default=False, help=SUPPRESS_HELP)
-    parser.add_option("--no-persistent-search", dest="persistent_search",
-                      default=True, action="store_false",
-                      help="Do not enable persistent search feature in the name server")
-    parser.add_option("--zone-refresh", dest="zone_refresh",
-                      default=0, type="int",
-                      help="When set to non-zero the name server will use DNS zone "
-                           "detection based on polling instead of a persistent search")
     parser.add_option("--no-serial-autoincrement", dest="serial_autoincrement",
                       default=True, action="store_false",
                       help="Do not enable SOA serial autoincrement")
@@ -80,18 +70,6 @@ def parse_options():
         if not options.forwarders and not options.no_forwarders:
             parser.error("You must specify at least one --forwarder option or --no-forwarders option")
 
-    if options.zone_refresh < 0:
-        parser.error("negative numbers not allowed for --zone-refresh")
-    elif options.zone_refresh > 0:
-        options.persistent_search = False   # mutually exclusive features
-
-    if options.zone_notif:
-        print >>sys.stderr, "WARNING: --zone-notif option is deprecated and has no effect"
-
-    if options.serial_autoincrement and not options.persistent_search:
-        parser.error('persistent search feature is required for '
-                     'DNS SOA serial autoincrement')
-
     return safe_options, options
 
 def main():
@@ -232,8 +210,6 @@ def main():
 
     bind.setup(api.env.host, ip_address, api.env.realm, api.env.domain,
                dns_forwarders, conf_ntp, reverse_zone, zonemgr=options.zonemgr,
-               zone_refresh=options.zone_refresh,
-               persistent_search=options.persistent_search,
                serial_autoincrement=options.serial_autoincrement)
     bind.create_instance()
 
diff --git a/install/tools/ipa-server-install b/install/tools/ipa-server-install
index cc88a0b1991bd467076038772dcac232a2d0b64b..bdd88628ae2fd4091570614dd145376d43b57fc5 100755
--- a/install/tools/ipa-server-install
+++ b/install/tools/ipa-server-install
@@ -207,16 +207,6 @@ def parse_options():
     dns_group.add_option("--zonemgr", action="callback", callback=bindinstance.zonemgr_callback,
                       type="string",
                       help="DNS zone manager e-mail address. Defaults to hostmaster@DOMAIN")
-    # this option name has been deprecated, persistent search has been enabled by default
-    dns_group.add_option("--zone-notif", dest="zone_notif",
-                      action="store_true", default=False, help=SUPPRESS_HELP)
-    dns_group.add_option("--no-persistent-search", dest="persistent_search",
-                      default=True, action="store_false",
-                      help="Do not enable persistent search feature in the name server")
-    dns_group.add_option("--zone-refresh", dest="zone_refresh",
-                      default=0, type="int",
-                      help="When set to non-zero the name server will use DNS zone "
-                           "detection based on polling instead of a persistent search")
     dns_group.add_option("--no-host-dns", dest="no_host_dns", action="store_true",
                       default=False,
                       help="Do not use DNS for hostname lookup during installation")
@@ -319,18 +309,6 @@ def parse_options():
     #Automatically disable pkinit w/ dogtag until that is supported
     options.setup_pkinit = False
 
-    if options.zone_refresh < 0:
-        parser.error("negative numbers not allowed for --zone-refresh")
-    elif options.zone_refresh > 0:
-        options.persistent_search = False   # mutually exclusive features
-
-    if options.serial_autoincrement and not options.persistent_search:
-        parser.error('persistent search feature is required for '
-                     'DNS SOA serial autoincrement')
-
-    if options.zone_notif:
-        print >>sys.stderr, "WARNING: --zone-notif option is deprecated and has no effect"
-
     return safe_options, options
 
 def signal_handler(signum, frame):
@@ -1130,8 +1108,6 @@ def main():
     bind = bindinstance.BindInstance(fstore, dm_password)
     bind.setup(host_name, ip_address, realm_name, domain_name, dns_forwarders,
                options.conf_ntp, reverse_zone, zonemgr=options.zonemgr,
-               zone_refresh=options.zone_refresh,
-               persistent_search=options.persistent_search,
                serial_autoincrement=options.serial_autoincrement,
                ca_configured=setup_ca)
     if options.setup_dns:
diff --git a/install/tools/ipa-upgradeconfig b/install/tools/ipa-upgradeconfig
index 4e9216964a045b5a87c22f6eb87bb1844f4adce9..857b4b479d78b4a7b9fc71c97fa22211578c11bc 100644
--- a/install/tools/ipa-upgradeconfig
+++ b/install/tools/ipa-upgradeconfig
@@ -355,7 +355,8 @@ def named_enable_psearch():
     if not sysupgrade.get_upgrade_state('named.conf', 'psearch_enabled'):
         if psearch != "yes":
             try:
-                bindinstance.named_conf_set_directive('zone_refresh', 0)
+                # Remove zone_refresh from configuration rather then set it to 0
+                bindinstance.named_conf_set_directive('zone_refresh', None)
                 bindinstance.named_conf_set_directive('psearch', 'yes')
             except IOError, e:
                 root_logger.error('Cannot enable psearch in %s: %s',
diff --git a/install/tools/man/ipa-dns-install.1 b/install/tools/man/ipa-dns-install.1
index b0bdca94f4aea4a17fecc3362a92a9885bbafed0..646601eecaded0d8490bb41945f4bd83ee81c087 100644
--- a/install/tools/man/ipa-dns-install.1
+++ b/install/tools/man/ipa-dns-install.1
@@ -49,12 +49,6 @@ Do not create new reverse DNS zone. If used on a replica and a reverse DNS zone
 \fB\-\-zonemgr\fR
 The e\-mail address of the DNS zone manager. Defaults to hostmaster@DOMAIN
 .TP
-\fB\-\-no\-persistent\-search\fR
-Do not enable persistent search mechanism for updating the list of DNS zones in the name server. When persistent search is disabled and \fB\-\-zone\-refresh\fR option is not set to non-zero value, new zones won't be resolvable until the name server is reloaded.
-.TP
-\fB\-\-zone\-refresh=\fIZONE_REFRESH\fR
-When set to non-zero value, persistent search zone update mechanism will be disabled and the name server will use a polling mechanism to load new DNS zones every \fIZONE_REFRESH\fR seconds.
-.TP
 \fB\-\-no\-serial\-autoincrement\fR
 Do not enable SOA serial autoincrement feature. SOA serial will have to be updated automatically or other DNS features like zone transfer od DNSSEC will not function properly. This feature requires persistent search zone update mechanism.
 .TP
diff --git a/install/tools/man/ipa-server-install.1 b/install/tools/man/ipa-server-install.1
index 59219c14727c5a3062d06d5ef02eb0eebdc9c4f2..5f81cec94afa241449c5d7dbde573d0c2c687d71 100644
--- a/install/tools/man/ipa-server-install.1
+++ b/install/tools/man/ipa-server-install.1
@@ -146,12 +146,6 @@ Do not create reverse DNS zone
 \fB\-\-zonemgr\fR
 The e\-mail address of the DNS zone manager. Defaults to hostmaster@DOMAIN
 .TP
-\fB\-\-no\-persistent\-search\fR
-Do not enable persistent search mechanism for updating the list of DNS zones in the name server. When persistent search is disabled and \fB\-\-zone\-refresh\fR option is not set to non-zero value, new zones won't be resolvable until the name server is reloaded.
-.TP
-\fB\-\-zone\-refresh=\fIZONE_REFRESH\fR
-When set to non-zero value, persistent search zone update mechanism will be disabled and the name server will use a polling mechanism to load new DNS zones every \fIZONE_REFRESH\fR seconds.
-.TP
 \fB\-\-no\-host\-dns\fR
 Do not use DNS for hostname lookup during installation
 .TP
diff --git a/ipaserver/install/bindinstance.py b/ipaserver/install/bindinstance.py
index ac86e9e7d5713172772b7868233cfa7da91a9fab..6c627db74ad75869011c94cce1e29650352f5606 100644
--- a/ipaserver/install/bindinstance.py
+++ b/ipaserver/install/bindinstance.py
@@ -463,8 +463,7 @@ class BindInstance(service.Service):
 
     def setup(self, fqdn, ip_address, realm_name, domain_name, forwarders, ntp,
               reverse_zone, named_user="named", zonemgr=None,
-              zone_refresh=0, persistent_search=True, serial_autoincrement=True,
-              ca_configured=None):
+              serial_autoincrement=True, ca_configured=None):
         self.named_user = named_user
         self.fqdn = fqdn
         self.ip_address = ip_address
@@ -475,8 +474,6 @@ class BindInstance(service.Service):
         self.suffix = ipautil.realm_to_suffix(self.realm)
         self.ntp = ntp
         self.reverse_zone = reverse_zone
-        self.zone_refresh = zone_refresh
-        self.persistent_search = persistent_search
         self.serial_autoincrement = serial_autoincrement
         self.ca_configured = ca_configured
 
@@ -593,24 +590,24 @@ class BindInstance(service.Service):
         else:
             ipa_ca = ""
 
-        boolean_var = {}
-        for var in ('persistent_search', 'serial_autoincrement'):
-            boolean_var[var] = "yes" if getattr(self, var, False) else "no"
+        def bool_to_yesno(var):
+            return "yes" if var else "no"
 
-        self.sub_dict = dict(FQDN=self.fqdn,
-                             IP=self.ip_address,
-                             DOMAIN=self.domain,
-                             HOST=self.host,
-                             REALM=self.realm,
-                             SERVER_ID=realm_to_serverid(self.realm),
-                             FORWARDERS=fwds,
-                             SUFFIX=self.suffix,
-                             OPTIONAL_NTP=optional_ntp,
-                             ZONEMGR=self.zonemgr,
-                             ZONE_REFRESH=self.zone_refresh,
-                             IPA_CA_RECORD=ipa_ca,
-                             PERSISTENT_SEARCH=boolean_var['persistent_search'],
-                             SERIAL_AUTOINCREMENT=boolean_var['serial_autoincrement'],)
+        self.sub_dict = dict(
+            FQDN=self.fqdn,
+            IP=self.ip_address,
+            DOMAIN=self.domain,
+            HOST=self.host,
+            REALM=self.realm,
+            SERVER_ID=realm_to_serverid(self.realm),
+            FORWARDERS=fwds,
+            SUFFIX=self.suffix,
+            OPTIONAL_NTP=optional_ntp,
+            ZONEMGR=self.zonemgr,
+            IPA_CA_RECORD=ipa_ca,
+            PERSISTENT_SEARCH="yes",
+            SERIAL_AUTOINCREMENT=bool_to_yesno(self.serial_autoincrement),
+            )
 
     def __setup_dns_container(self):
         self._ldap_mod("dns.ldif", self.sub_dict)
-- 
1.8.3.1

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

Reply via email to