From f199c5dbc09912a185feda5aa87dc82e2800ad6a Mon Sep 17 00:00:00 2001
From: Andrew Bartlett <abartlet@samba.org>
Date: Sun, 24 Jun 2012 16:31:37 +1000
Subject: s4-classicupgrade: Allow DNS backend to be specified

---
 source4/scripting/python/samba/netcmd/domain.py | 12 ++++++++++--
 source4/scripting/python/samba/upgrade.py       |  6 ++----
 2 files changed, 12 insertions(+), 6 deletions(-)

(limited to 'source4/scripting/python')

diff --git a/source4/scripting/python/samba/netcmd/domain.py b/source4/scripting/python/samba/netcmd/domain.py
index e4b1241229..8199c41aba 100644
--- a/source4/scripting/python/samba/netcmd/domain.py
+++ b/source4/scripting/python/samba/netcmd/domain.py
@@ -839,12 +839,20 @@ class cmd_domain_classicupgrade(Command):
         Option("--verbose", help="Be verbose", action="store_true"),
         Option("--use-xattrs", type="choice", choices=["yes","no","auto"], metavar="[yes|no|auto]",
                    help="Define if we should use the native fs capabilities or a tdb file for storing attributes likes ntacl, auto tries to make an inteligent guess based on the user rights and system capabilities", default="auto"),
+        Option("--dns-backend", type="choice", metavar="NAMESERVER-BACKEND",
+               choices=["SAMBA_INTERNAL", "BIND9_FLATFILE", "BIND9_DLZ", "NONE"],
+               help="The DNS server backend. SAMBA_INTERNAL is the builtin name server, " \
+                   "BIND9_FLATFILE uses bind9 text database to store zone information, " \
+                   "BIND9_DLZ uses samba4 AD to store zone information (default), " \
+                   "NONE skips the DNS setup entirely (this DC will not be a DNS server)",
+               default="BIND9_DLZ")
     ]
 
     takes_args = ["smbconf"]
 
     def run(self, smbconf=None, targetdir=None, dbdir=None, testparm=None, 
-            quiet=False, verbose=False, use_xattrs=None, sambaopts=None, versionopts=None):
+            quiet=False, verbose=False, use_xattrs=None, sambaopts=None, versionopts=None,
+            dns_backend=None):
 
         if not os.path.exists(smbconf):
             raise CommandError("File %s does not exist" % smbconf)
@@ -928,7 +936,7 @@ class cmd_domain_classicupgrade(Command):
     
         logger.info("Provisioning")
         upgrade_from_samba3(samba3, logger, targetdir, session_info=system_session(), 
-                            useeadb=eadb)
+                            useeadb=eadb, dns_backend=dns_backend)
 
 class cmd_domain(SuperCommand):
     """Domain management"""
diff --git a/source4/scripting/python/samba/upgrade.py b/source4/scripting/python/samba/upgrade.py
index 3ef79ed646..8ecc6026a6 100644
--- a/source4/scripting/python/samba/upgrade.py
+++ b/source4/scripting/python/samba/upgrade.py
@@ -485,7 +485,7 @@ def import_registry(samba4_registry, samba3_regdb):
             key_handle.set_value(value_name, value_type, value_data)
 
 
-def upgrade_from_samba3(samba3, logger, targetdir, session_info=None, useeadb=False):
+def upgrade_from_samba3(samba3, logger, targetdir, session_info=None, useeadb=False, dns_backend=None):
     """Upgrade from samba3 database to samba4 AD database
 
     :param samba3: samba3 object
@@ -689,9 +689,7 @@ Please fix this account before attempting to upgrade again
             logger.error("   %s" % str(sid))
         raise ProvisioningError("Please remove duplicate sid entries before upgrade.")
 
-    if serverrole == "ROLE_DOMAIN_BDC" or serverrole == "ROLE_DOMAIN_PDC":
-        dns_backend = "BIND9_DLZ"
-    else:
+    if not (serverrole == "ROLE_DOMAIN_BDC" or serverrole == "ROLE_DOMAIN_PDC"):
         dns_backend = "NONE"
 
     # Do full provision
-- 
cgit