s4-python: Avoid importing glue directly.
authorJelmer Vernooij <jelmer@samba.org>
Sat, 3 Apr 2010 22:30:34 +0000 (00:30 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Sat, 3 Apr 2010 22:30:34 +0000 (00:30 +0200)
source4/lib/ldb/tests/python/urgent_replication.py
source4/scripting/python/samba/__init__.py
source4/scripting/python/samba/provision.py
source4/scripting/python/samba/samdb.py

index 28b3a5fa781a6c9ee69a146b527d2d98918f42b4..86d6d6515a52c44be443e50a6f70167b6b569868 100755 (executable)
@@ -13,10 +13,8 @@ sys.path.append("../lib/testtools")
 import samba.getopt as options
 
 from samba.auth import system_session
-from ldb import SCOPE_BASE, LdbError
-from ldb import ERR_NO_SUCH_OBJECT
-from ldb import Message, MessageElement, Dn
-from ldb import FLAG_MOD_REPLACE
+from ldb import (SCOPE_BASE, LdbError, ERR_NO_SUCH_OBJECT, Message,
+    MessageElement, Dn, FLAG_MOD_REPLACE)
 from samba import Ldb
 from samba import glue
 
index 7299e113925d7269316ef4d1cfd6c526f79c98b5..dd876f910d27ed6a5ed8c5949870fe1eaa7f4968 100644 (file)
@@ -45,6 +45,8 @@ import ldb
 import dsdb
 import glue
 
+
+
 class Ldb(ldb.Ldb):
     """Simple Samba-specific LDB subclass that takes care
     of setting up the modules dir, credentials pointers, etc.
@@ -414,3 +416,7 @@ def ensure_external_module(modulename, location):
                 "samba.external.%s" % modulename, fromlist=["samba.external"])
 
 version = glue.version
+interface_ips = glue.interface_ips
+set_debug_level = glue.set_debug_level
+unix2nttime = glue.unix2nttime
+generate_random_password = glue.generate_random_password
index e527b024c93a15702a3bb92496720745825560d6..6bae97bd977377cf485cb34b6ce70482ba11873d 100644 (file)
@@ -1,4 +1,4 @@
-#
+
 # Unix SMB/CIFS implementation.
 # backend code for provisioning a Samba4 server
 
@@ -40,7 +40,8 @@ import shutil
 import ldb
 
 from samba.auth import system_session, admin_session
-from samba import glue, version, Ldb, substitute_var, valid_netbios_name
+import samba
+from samba import version, Ldb, substitute_var, valid_netbios_name
 from samba import check_all_substituted, read_and_sub_file, setup_file
 from samba.dsdb import DS_DOMAIN_FUNCTION_2003, DS_DC_FUNCTION_2008
 from samba.dcerpc import security
@@ -1120,16 +1121,16 @@ def provision(setup_dir, message, session_info,
     policyguid_dc = policyguid_dc.upper()
 
     if adminpass is None:
-        adminpass = glue.generate_random_password(12, 32)
+        adminpass = samba.generate_random_password(12, 32)
     if krbtgtpass is None:
-        krbtgtpass = glue.generate_random_password(128, 255)
+        krbtgtpass = samba.generate_random_password(128, 255)
     if machinepass is None:
-        machinepass  = glue.generate_random_password(128, 255)
+        machinepass  = samba.generate_random_password(128, 255)
     if dnspass is None:
-        dnspass = glue.generate_random_password(128, 255)
+        dnspass = samba.generate_random_password(128, 255)
     if ldapadminpass is None:
         #Make a new, random password between Samba and it's LDAP server
-        ldapadminpass=glue.generate_random_password(128, 255)
+        ldapadminpass=samba.generate_random_password(128, 255)
 
     if backend_type is None:
         backend_type = "ldb"
@@ -1184,7 +1185,7 @@ def provision(setup_dir, message, session_info,
     paths.bind_gid = bind_gid
 
     if hostip is None:
-        hostips = glue.interface_ips(lp, False)
+        hostips = samba.interface_ips(lp, False)
         if len(hostips) == 0:
             message("No external IPv4 address has been found: I use the loopback.")
             hostip = '127.0.0.1'
@@ -1449,7 +1450,7 @@ def provision_become_dc(setup_dir=None,
         """print a message if quiet is not set."""
         print text
 
-    glue.set_debug_level(debuglevel)
+    samba.set_debug_level(debuglevel)
 
     return provision(setup_dir, message, system_session(), None,
               smbconf=smbconf, targetdir=targetdir, samdb_fill=FILL_DRS,
index f3622fe1b1a1789c79dda7f7f7df2d75b3efb8d0..22e8f462264f4fdc91c87b3489b3f4546878e7fa 100644 (file)
@@ -44,7 +44,7 @@ class SamDB(samba.Ldb):
 
         self.lp = lp
         if url is None:
-                url = lp.get("sam database")
+            url = lp.get("sam database")
 
         super(SamDB, self).__init__(url=url, lp=lp, modules_dir=modules_dir,
                 session_info=session_info, credentials=credentials, flags=flags,
@@ -214,7 +214,7 @@ userPassword:: %s
                 accountExpires = 0
             else:
                 userAccountControl = userAccountControl & ~0x10000
-                accountExpires = glue.unix2nttime(expiry_seconds + int(time.time()))
+                accountExpires = samba.unix2nttime(expiry_seconds + int(time.time()))
 
             setexp = """
 dn: %s
@@ -230,4 +230,3 @@ accountExpires: %u
             self.transaction_cancel()
             raise
         self.transaction_commit()
-