These 2 patches changes the DNS API to support the last missing bits in
new bind-dyndb-ldap:

1) Both global and per-zone forwarders now support a conditional custom
port (with format "IP_ADDRESS PORT")
2) Missing global configuration options have been added:
 * idnsforwardpolicy: Default policy for conditional forwarding
 * idnsallowsyncptr: Allow globaly PTR synchronization for dynamic
   updates
 * idnszonerefresh: Default interval between regular polls of the
   name server for new DNS zones

Before these patches are pushed, I will just have to update the minimal
bind-dyndb-ldap version (it has not been built yet) which have a full
support for these.

Martin
>From 01a440ac9498cb8597234267410dca8de1edde97 Mon Sep 17 00:00:00 2001
From: Martin Kosek <mko...@redhat.com>
Date: Thu, 1 Mar 2012 11:35:00 +0100
Subject: [PATCH 1/2] Allow port numbers for idnsForwarders

Let user enter custom ports for zone conditional forwarders or
global forwarders in dnsconfig. Ports can be specified in
a standard BIND format: IP_ADDRESS [PORT]

https://fedorahosted.org/freeipa/ticket/2462
---
 ipalib/plugins/dns.py |   26 ++++++++++++++++++++++----
 1 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py
index b7f86e20164d88d6d4d2ab0086d2f0cf6baee8c2..04a1f92de95d64f2486e9e22f3590cfa6a9fe70a 100644
--- a/ipalib/plugins/dns.py
+++ b/ipalib/plugins/dns.py
@@ -299,6 +299,24 @@ def _normalize_bind_aci(bind_acis):
     acis += u';'
     return acis
 
+def _validate_bind_forwarder(ugettext, forwarder):
+    ip_address, space, port = forwarder.partition(u' ')
+
+    ip_address_validation = _validate_ipaddr(ugettext, ip_address)
+
+    if ip_address_validation is not None:
+        return ip_address_validation
+
+    if port:
+        try:
+            port = int(port)
+            if port < 0 or port > 65535:
+                raise ValueError()
+        except ValueError:
+            return _('%(port)s is not a valid port' % dict(port=port))
+
+    return None
+
 def _domain_name_validator(ugettext, value):
     try:
         # Allow domain name which is not fully qualified. These are supported
@@ -1540,10 +1558,10 @@ class dnszone(LDAPObject):
             autofill=True,
         ),
         Str('idnsforwarders*',
-            _validate_ipaddr,
+            _validate_bind_forwarder,
             cli_name='forwarder',
             label=_('Zone forwarders'),
-            doc=_('A list of zone forwarders'),
+            doc=_('A list of zone forwarders. A custom port can be specified for each forwarder using a format "IP_ADDRESS PORT"'),
             csv=True,
         ),
         StrEnum('idnsforwardpolicy?',
@@ -2477,10 +2495,10 @@ class dnsconfig(LDAPObject):
 
     takes_params = (
         Str('idnsforwarders*',
-            _validate_ipaddr,
+            _validate_bind_forwarder,
             cli_name='forwarder',
             label=_('Global forwarders'),
-            doc=_('A list of global forwarders'),
+            doc=_('A list of global forwarders. A custom port can be specified for each forwarder using a format "IP_ADDRESS PORT"'),
             csv=True,
         ),
     )
-- 
1.7.7.6

>From 1b3ea1be1ecf4f17c6951ba11552d896a7b3d263 Mon Sep 17 00:00:00 2001
From: Martin Kosek <mko...@redhat.com>
Date: Thu, 1 Mar 2012 13:09:20 +0100
Subject: [PATCH 2/2] Add missing global options in dnsconfig

Add a support for new global options in bind-dyndb-ldap, that is:
 * idnsforwardpolicy: Default policy for conditional forwarding
 * idnsallowsyncptr: Allow globaly PTR synchronization for dynamic
   updates
 * idnszonerefresh: Default interval between regular polls of the
   name server for new DNS zones

https://fedorahosted.org/freeipa/ticket/2439
---
 API.txt                              |    5 ++++-
 ipalib/plugins/dns.py                |   21 ++++++++++++++++++++-
 tests/test_xmlrpc/test_dns_plugin.py |    6 +++++-
 3 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/API.txt b/API.txt
index 73d115c0548230fa06fb6142474715606568e1f5..e344215bc19c0ed87f01ac3617459cccb4967051 100644
--- a/API.txt
+++ b/API.txt
@@ -611,8 +611,11 @@ output: Output('summary', (<type 'unicode'>, <type 'NoneType'>), None)
 output: Output('result', <type 'bool'>, None)
 output: Output('value', <type 'unicode'>, None)
 command: dnsconfig_mod
-args: 0,8,3
+args: 0,11,3
 option: Str('idnsforwarders', attribute=True, autofill=False, cli_name='forwarder', csv=True, multivalue=True, required=False)
+option: StrEnum('idnsforwardpolicy', attribute=True, autofill=False, cli_name='forward_policy', multivalue=False, required=False, values=(u'only', u'first'))
+option: Bool('idnsallowsyncptr', attribute=True, autofill=False, cli_name='allow_sync_ptr', multivalue=False, required=False)
+option: Int('idnszonerefresh', attribute=True, autofill=False, cli_name='zone_refresh', minvalue=0, multivalue=False, required=False)
 option: Str('setattr*', cli_name='setattr', exclude='webui')
 option: Str('addattr*', cli_name='addattr', exclude='webui')
 option: Str('delattr*', cli_name='delattr', exclude='webui')
diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py
index 04a1f92de95d64f2486e9e22f3590cfa6a9fe70a..7ce496e3793bac37a98637c8fe9fff61aac60d23 100644
--- a/ipalib/plugins/dns.py
+++ b/ipalib/plugins/dns.py
@@ -2488,7 +2488,10 @@ class dnsconfig(LDAPObject):
     DNS global configuration object
     """
     object_name = _('DNS configuration options')
-    default_attributes = [ 'idnsforwarders', ]
+    default_attributes = [
+        'idnsforwardpolicy', 'idnsforwarders', 'idnsallowsyncptr',
+        'idnszonerefresh'
+    ]
 
     label = _('DNS Global Configuration')
     label_singular = _('DNS Global Configuration')
@@ -2501,6 +2504,22 @@ class dnsconfig(LDAPObject):
             doc=_('A list of global forwarders. A custom port can be specified for each forwarder using a format "IP_ADDRESS PORT"'),
             csv=True,
         ),
+        StrEnum('idnsforwardpolicy?',
+            cli_name='forward_policy',
+            label=_('Forward policy'),
+            values=(u'only', u'first',),
+        ),
+        Bool('idnsallowsyncptr?',
+            cli_name='allow_sync_ptr',
+            label=_('Allow PTR sync'),
+            doc=_('Allow synchronization of forward (A, AAAA) and reverse (PTR) records'),
+        ),
+        Int('idnszonerefresh?',
+            cli_name='zone_refresh',
+            label=_('Zone refresh interval'),
+            doc=_('An interval between regular polls of the name server for new DNS zones'),
+            minvalue=0,
+        ),
     )
 
     def get_dn(self, *keys, **kwargs):
diff --git a/tests/test_xmlrpc/test_dns_plugin.py b/tests/test_xmlrpc/test_dns_plugin.py
index 7b1a45321801be20ae90b71ba9bbbf0c4bce03c5..3c440e1538852f0d05e9e8869a32b4e82eae121d 100644
--- a/tests/test_xmlrpc/test_dns_plugin.py
+++ b/tests/test_xmlrpc/test_dns_plugin.py
@@ -66,7 +66,11 @@ class test_dns(Declarative):
         ('dnsrecord_del', [dnszone1, dnsres1], {'del_all' : True}),
         ('dnszone_del', [dnszone2], {}),
         ('dnszone_del', [revdnszone1], {}),
-        ('dnsconfig_mod', [], {'idnsforwarders' : None,})
+        ('dnsconfig_mod', [], {'idnsforwarders' : None,
+                               'idnsforwardpolicy' : None,
+                               'idnsallowsyncptr' : None,
+                               'idnszonerefresh' : None,
+                               })
     ]
 
     tests = [
-- 
1.7.7.6

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

Reply via email to