s4 upgradeprovision: Inform about new dns dynamic update if the provision didn't...
authorMatthieu Patou <mat@matws.net>
Thu, 8 Apr 2010 22:55:38 +0000 (02:55 +0400)
committerJelmer Vernooij <jelmer@samba.org>
Sat, 19 Jun 2010 22:43:07 +0000 (00:43 +0200)
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
source4/scripting/bin/upgradeprovision

index 9ecd0b8a4adc9cfcc9a392de532fcc55e938cedc..e76903d2101817bf31b22c3fa467f70c542e0f2b 100755 (executable)
@@ -160,9 +160,46 @@ def identic_rename(ldbobj,dn):
 
     :param lbdobj: An Ldb Object
     :param dn: DN of the object to manipulate """
-    (before,sep,after)=str(dn).partition('=')
-    ldbobj.rename(dn,Dn(ldbobj,"%s=foo%s"%(before,after)))
-    ldbobj.rename(Dn(ldbobj,"%s=foo%s"%(before,after)),dn)
+
+    (before, sep, after)=str(dn).partition('=')
+    ldbobj.rename(dn, Dn(ldbobj, "%s=foo%s" % (before, after)))
+    ldbobj.rename(Dn(ldbobj, "%s=foo%s" % (before, after)), dn)
+
+def check_for_DNS(refprivate, private):
+    """Check if the provision has already the requirement for dynamic dns
+
+    :param refprivate: The path to the private directory of the reference
+                       provision
+    :param private: The path to the private directory of the upgraded
+                    provision"""
+
+    spnfile = "%s/spn_update_list" % private
+    namedfile = lp.get("dnsupdate:path")
+
+    if not namedfile:
+       namedfile = "%s/named.conf.update" % private
+
+    if not os.path.exists(spnfile):
+        shutil.copy("%s/spn_update_list" % refprivate, "%s" % spnfile)
+
+    destdir = "%s/new_dns" % private
+    dnsdir = "%s/dns" % private
+
+    if not os.path.exists(namedfile):
+        if not os.path.exists(destdir):
+            os.mkdir(destdir)
+        if not os.path.exists(dnsdir):
+            os.mkdir(dnsdir)
+        shutil.copy("%s/named.conf" % refprivate, "%s/named.conf" % destdir)
+        shutil.copy("%s/named.txt" % refprivate, "%s/named.txt" % destdir)
+        message(SIMPLE, "It seems that you provision didn't integrate new rules "
+                "for dynamic dns update of domain related entries")
+        message(SIMPLE, "A copy of the new bind configuration files and "
+                "template as been put in %s, you should read them and configure dynamic "
+                " dns update" % destdir)
+
+
+#    dnsupdate:path
 
 
 def populate_backlink(samdb, schemadn):
@@ -1115,6 +1152,7 @@ if __name__ == '__main__':
         check_updated_sd(new_ldbs.sam,ldbs.sam, names)
 
     updateOEMInfo(ldbs.sam,names)
+    check_for_DNS(newpaths.private_dir, paths.private_dir)
     updateProvisionUSN(ldbs.sam,names)
     ldbs.groupedCommit()
     new_ldbs.groupedCommit()