[PATCH] s4:provision - Added setup() method in LDAPBackend.

Endi S. Dewata edewata at redhat.com
Thu Nov 5 17:49:37 MST 2009


---
 source4/scripting/python/samba/provision.py        |    2 +-
 source4/scripting/python/samba/provisionbackend.py |   56 +++++++++++---------
 2 files changed, 32 insertions(+), 26 deletions(-)

diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py
index c102aee..77dcbd7 100644
--- a/source4/scripting/python/samba/provision.py
+++ b/source4/scripting/python/samba/provision.py
@@ -1225,7 +1225,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
diff --git a/source4/scripting/python/samba/provisionbackend.py b/source4/scripting/python/samba/provisionbackend.py
index b4239ef..da17cbf 100644
--- a/source4/scripting/python/samba/provisionbackend.py
+++ b/source4/scripting/python/samba/provisionbackend.py
@@ -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", {
-- 
1.6.0.6


------=_Part_70877_336007795.1257535627130
Content-Type: application/mbox;
	name=0006-s4-provision-Added-constructors-for-FDSBackend-and.patch
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename=0006-s4-provision-Added-constructors-for-FDSBackend-and.patch



More information about the samba-technical mailing list