s4:provision - Added setup() method in LDAPBackend.
authorEndi S. Dewata <edewata@redhat.com>
Fri, 6 Nov 2009 00:49:37 +0000 (18:49 -0600)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 12 Nov 2009 11:23:21 +0000 (22:23 +1100)
source4/scripting/python/samba/provision.py
source4/scripting/python/samba/provisionbackend.py

index e40603a0b0c2c0721c21d4574ec25947ff0b042d..f803f588eb2d8f65496d2c8e27a324c7a10ad48d 100644 (file)
@@ -1278,7 +1278,7 @@ def provision(setup_dir, message, session_info,
     else:
         raise ProvisioningError("Unknown LDAP backend type selected")
 
-    provision_backend.provision()
+    provision_backend.setup()
     provision_backend.start()
 
     # only install a new shares config db if there is none
index b4239ef92d829c73428a210682e44a8d0c3b005b..da17cbf05c1cbd8ec087b7b3337db337071ad432 100644 (file)
@@ -115,7 +115,22 @@ class ProvisionBackend(object):
 
             self.ldap_backend_type = "openldap" #For now, assume existing backends at least emulate OpenLDAP
             return
-    
+
+    def setup(self):
+        pass
+
+    def start(self):
+        pass
+
+    def shutdown(self):
+        pass
+
+    def post_setup(self):
+        pass
+
+
+class LDAPBackend(ProvisionBackend):
+    def setup(self):
         # we will shortly start slapd with ldapi for final provisioning. first check with ldapsearch -> rootDSE via self.ldapi_uri
         # if another instance of slapd is already running 
         try:
@@ -123,10 +138,10 @@ class ProvisionBackend(object):
             search_ol_rootdse = ldapi_db.search(base="", scope=SCOPE_BASE,
                                                 expression="(objectClass=OpenLDAProotDSE)");
             try:
-                f = open(paths.slapdpid, "r")
+                f = open(self.paths.slapdpid, "r")
                 p = f.read()
                 f.close()
-                message("Check for slapd Process with PID: " + str(p) + " and terminate it manually.")
+                self.message("Check for slapd Process with PID: " + str(p) + " and terminate it manually.")
             except:
                 pass
             
@@ -136,54 +151,45 @@ class ProvisionBackend(object):
             pass
 
         # Try to print helpful messages when the user has not specified the path to slapd
-        if slapd_path is None:
+        if self.slapd_path is None:
             raise ProvisioningError("Warning: LDAP-Backend must be setup with path to slapd, e.g. --slapd-path=\"/usr/local/libexec/slapd\"!")
-        if not os.path.exists(slapd_path):
-            message (slapd_path)
+        if not os.path.exists(self.slapd_path):
+            self.message (self.slapd_path)
             raise ProvisioningError("Warning: Given Path to slapd does not exist!")
 
 
-        if not os.path.isdir(paths.ldapdir):
-            os.makedirs(paths.ldapdir, 0700)
+        if not os.path.isdir(self.paths.ldapdir):
+            os.makedirs(self.paths.ldapdir, 0700)
 
         # Put the LDIF of the schema into a database so we can search on
         # it to generate schema-dependent configurations in Fedora DS and
         # OpenLDAP
-        schemadb_path = os.path.join(paths.ldapdir, "schema-tmp.ldb")
+        schemadb_path = os.path.join(self.paths.ldapdir, "schema-tmp.ldb")
         try:
             os.unlink(schemadb_path)
         except OSError:
             pass
 
-        schema.write_to_tmp_ldb(schemadb_path);
+        self.schema.write_to_tmp_ldb(schemadb_path);
 
         self.credentials = Credentials()
-        self.credentials.guess(lp)
+        self.credentials.guess(self.lp)
         #Kerberos to an ldapi:// backend makes no sense
         self.credentials.set_kerberos_state(DONT_USE_KERBEROS)
-        self.credentials.set_password(ldapadminpass)
+        self.credentials.set_password(self.ldapadminpass)
 
         self.secrets_credentials = Credentials()
-        self.secrets_credentials.guess(lp)
+        self.secrets_credentials.guess(self.lp)
         #Kerberos to an ldapi:// backend makes no sense
         self.secrets_credentials.set_kerberos_state(DONT_USE_KERBEROS)
         self.secrets_credentials.set_username("samba-admin")
-        self.secrets_credentials.set_password(ldapadminpass)
+        self.secrets_credentials.set_password(self.ldapadminpass)
 
-    def provision(self):
-        pass
+        self.provision()
 
-    def start(self):
-        pass
-
-    def shutdown(self):
-        pass
-
-    def post_setup(self):
+    def provision(self):
         pass
 
-
-class LDAPBackend(ProvisionBackend):
     def start(self):
         self.slapd_command_escaped = "\'" + "\' \'".join(self.slapd_command) + "\'"
         setup_file(self.setup_path("ldap_backend_startup.sh"), self.paths.ldapdir + "/ldap_backend_startup.sh", {