From 432034569cab4a638eff8ad3e79e00bdd9af194d Mon Sep 17 00:00:00 2001
From: Antonio Torres <antorres@redhat.com>
Date: Wed, 16 Jun 2021 17:41:57 +0200
Subject: [PATCH] dnszone-add: deprecate option for setting SOA serial

Since IPA 3 [1] SOA serial is managed automatically via autoincrement,
and the option of disabling this behavior was deprecated in IPA 3.3.3 [2].
As a result, the option '--serial' during DNS zone addition would be
ignored as it is set during the creation. This commit adds a deprecation
warning if this option is used. Setting the SOA serial manually would still
be useful in certain scenarios, so the option of doing it with dnszone-mod
is kept.

[1]: https://www.freeipa.org/page/V3/DNS_SOA_serial_auto-incrementation
[2]: https://www.freeipa.org/page/Releases/3.3.3

Fixes: https://pagure.io/freeipa/issue/8227
Signed-off-by: Antonio Torres <antorres@redhat.com>
---
 ipaserver/plugins/dns.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/ipaserver/plugins/dns.py b/ipaserver/plugins/dns.py
index acb16613cd3..528c13b4e53 100644
--- a/ipaserver/plugins/dns.py
+++ b/ipaserver/plugins/dns.py
@@ -2776,6 +2776,14 @@ def _warning_deprecated_option(self, result, **options):
                     option='ip-address',
                     additional_info=u"Value will be ignored.")
             )
+        if 'idnssoaserial' in options:
+            messages.add_message(
+                options['version'],
+                result,
+                messages.OptionDeprecatedWarning(
+                    option='idnssoaserial',
+                    additional_info=u"Value will be ignored.")
+            )
 
     def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options):
         assert isinstance(dn, DN)
