Ticket: https://fedorahosted.org/freeipa/ticket/3210#comment:16
Patch attached.
-- 
Martin^2 Basti
>From 9334ebbe6f7965496faec63c15324dfc3eea6471 Mon Sep 17 00:00:00 2001
From: Martin Basti <mba...@redhat.com>
Date: Mon, 30 Jun 2014 11:58:46 +0200
Subject: [PATCH] Add warning about semantic change for zones

--forwarder, --forward-policy have different semantic since
forward zones support.
Add warning if zone contains forwarders or specified policy.

Ticket: https://fedorahosted.org/freeipa/ticket/3210#comment:16
---
 ipalib/plugins/dns.py | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py
index 9de542b0f61e877fef201e237c003eba7db24672..b693bb9c3ce091fa26ed14d27213b84ef61f8f0c 100644
--- a/ipalib/plugins/dns.py
+++ b/ipalib/plugins/dns.py
@@ -36,6 +36,7 @@ from ipalib.parameters import (Flag, Bool, Int, Decimal, Str, StrEnum, Any,
 from ipalib.plugable import Registry
 from ipalib.plugins.baseldap import *
 from ipalib import _, ngettext
+from ipalib import messages
 from ipalib.util import (validate_zonemgr, normalize_zonemgr,
                          get_dns_forward_zone_update_policy,
                          get_dns_reverse_zone_update_policy,
@@ -267,6 +268,13 @@ _output_permissions = (
     output.Output('value', unicode, _('Permission value')),
 )
 
+forwarders_warning = _(
+"""DNS forwarder and forward-policy semantics changed in IPA 4.0.
+You may want to use forward zones (dnsforwardzone-*) instead. For more details read the docs.
+"""
+)
+
+
 def _rname_validator(ugettext, zonemgr):
     try:
         validate_zonemgr(zonemgr)
@@ -2204,6 +2212,14 @@ class dnszone(DNSZoneBase):
             return
         _records_idn_postprocess(record, **options)
 
+    def _warning_forwarding(self, result, **options):
+        if ('idnsforwarders' in result['result'] or
+            'idnsforwardpolicy' in result['result']
+        ):
+            messages.add_message(options['version'], result,
+                                 messages.PublicMessage(type='warning',
+                                 message=forwarders_warning))
+
 
 
 @register()
@@ -2292,6 +2308,11 @@ class dnszone_add(DNSZoneBase_add):
         entry_attrs['idnssoamname'] = nameserver
         return dn
 
+    def execute(self, *keys, **options):
+        result = super(dnszone_add, self).execute(*keys, **options)
+        self.obj._warning_forwarding(result, **options)
+        return result
+
     def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
         assert isinstance(dn, DN)
         nameserver_ip_address = options.get('ip_address')
@@ -2369,6 +2390,11 @@ class dnszone_mod(DNSZoneBase_mod):
 
         return dn
 
+    def execute(self, *keys, **options):
+        result = super(dnszone_mod, self).execute(*keys, **options)
+        self.obj._warning_forwarding(result, **options)
+        return result
+
     def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
         assert isinstance(dn, DN)
         self.obj._rr_zone_postprocess(entry_attrs, **options)
-- 
1.8.3.1

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

Reply via email to