s4:provision - Moved setup_db_config() into OpenLDAPBackend class.
authorEndi S. Dewata <edewata@redhat.com>
Fri, 29 Jan 2010 09:24:20 +0000 (03:24 -0600)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 2 Mar 2010 03:07:10 +0000 (14:07 +1100)
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
source4/scripting/python/samba/provisionbackend.py

index 9018f0f7cb734cedaf435ca84766e4b70f4e8aaa..75e00979dfe7a6c38bf6813b94d10182f7c18ab0 100644 (file)
@@ -42,19 +42,6 @@ from samba.credentials import Credentials, DONT_USE_KERBEROS
 from samba.schema import Schema
 from samba.provisionexceptions import ProvisioningError
 
-def setup_db_config(setup_path, dbdir):
-    """Setup a Berkeley database.
-    
-    :param setup_path: Setup path function.
-    :param dbdir: Database directory."""
-    if not os.path.isdir(os.path.join(dbdir, "bdb-logs")):
-        os.makedirs(os.path.join(dbdir, "bdb-logs"), 0700)
-        if not os.path.isdir(os.path.join(dbdir, "tmp")):
-            os.makedirs(os.path.join(dbdir, "tmp"), 0700)
-
-    setup_file(setup_path("DB_CONFIG"), os.path.join(dbdir, "DB_CONFIG"),
-               {"LDAPDBDIR": dbdir})
-
 class ProvisionBackend(object):
     def __init__(self, backend_type, paths=None, setup_path=None, lp=None, credentials=None, 
                  names=None, message=None):
@@ -310,6 +297,19 @@ class OpenLDAPBackend(LDAPBackend):
                 serverdn=self.names.serverdn,
                 files=[setup_path("schema_samba4.ldif")])
 
+    def setup_db_config(self, dbdir):
+        """Setup a Berkeley database.
+    
+        :param setup_path: Setup path function.
+        :param dbdir: Database directory."""
+        if not os.path.isdir(os.path.join(dbdir, "bdb-logs")):
+            os.makedirs(os.path.join(dbdir, "bdb-logs"), 0700)
+            if not os.path.isdir(os.path.join(dbdir, "tmp")):
+                os.makedirs(os.path.join(dbdir, "tmp"), 0700)
+
+        setup_file(self.setup_path("DB_CONFIG"), os.path.join(dbdir, "DB_CONFIG"),
+                   {"LDAPDBDIR": dbdir})
+
     def provision(self):
         # Wipe the directories so we can start
         shutil.rmtree(os.path.join(self.ldapdir, "db"), True)
@@ -442,9 +442,9 @@ class OpenLDAPBackend(LDAPBackend):
                     "INDEX_CONFIG": index_config,
                     "NOSYNC": nosync_config})
         
-        setup_db_config(self.setup_path, os.path.join(self.ldapdir, "db", "user"))
-        setup_db_config(self.setup_path, os.path.join(self.ldapdir, "db", "config"))
-        setup_db_config(self.setup_path, os.path.join(self.ldapdir, "db", "schema"))
+        self.setup_db_config(os.path.join(self.ldapdir, "db", "user"))
+        self.setup_db_config(os.path.join(self.ldapdir, "db", "config"))
+        self.setup_db_config(os.path.join(self.ldapdir, "db", "schema"))
     
         if not os.path.exists(os.path.join(self.ldapdir, "db", "samba",  "cn=samba")):
             os.makedirs(os.path.join(self.ldapdir, "db", "samba",  "cn=samba"), 0700)