summaryrefslogtreecommitdiff
path: root/source4/scripting/python
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2009-03-06 12:14:08 +1100
committerAndrew Bartlett <abartlet@samba.org>2009-03-06 12:14:08 +1100
commit4c32d8f1a704c9d6df09f62cc5f4caa569687c5e (patch)
treef790759dda8d7e8d2c412f228a27c45f5650b75d /source4/scripting/python
parent8374d6f0dc1d6ce6c554b10b5133bd77c5ad6292 (diff)
downloadsamba-4c32d8f1a704c9d6df09f62cc5f4caa569687c5e.tar.gz
samba-4c32d8f1a704c9d6df09f62cc5f4caa569687c5e.tar.bz2
samba-4c32d8f1a704c9d6df09f62cc5f4caa569687c5e.zip
Load the schema for provision-backend in a transaction
Loading data in a transaction is faster than without. Andrew Bartlett
Diffstat (limited to 'source4/scripting/python')
-rw-r--r--source4/scripting/python/samba/provision.py42
1 files changed, 24 insertions, 18 deletions
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py
index ed6548b13b..d089cb2513 100644
--- a/source4/scripting/python/samba/provision.py
+++ b/source4/scripting/python/samba/provision.py
@@ -1246,26 +1246,32 @@ def provision_backend(setup_dir=None, message=None,
pass
schemadb = SamDB(schemadb_path, lp=lp)
+ schemadb.transaction_start()
+ try:
- prefixmap = open(setup_path("prefixMap.txt"), 'r').read()
+ prefixmap = open(setup_path("prefixMap.txt"), 'r').read()
- setup_add_ldif(schemadb, setup_path("provision_schema_basedn.ldif"),
- {"SCHEMADN": names.schemadn,
- "ACI": "#",
- })
- setup_modify_ldif(schemadb,
- setup_path("provision_schema_basedn_modify.ldif"), \
- {"SCHEMADN": names.schemadn,
- "NETBIOSNAME": names.netbiosname,
- "DEFAULTSITE": DEFAULTSITE,
- "CONFIGDN": names.configdn,
- "SERVERDN": names.serverdn,
- "PREFIXMAP_B64": b64encode(prefixmap)
- })
-
- data = load_schema(setup_path, schemadb, names.schemadn, names.netbiosname,
- names.configdn, DEFAULTSITE, names.serverdn)
- schemadb.add_ldif(data)
+ setup_add_ldif(schemadb, setup_path("provision_schema_basedn.ldif"),
+ {"SCHEMADN": names.schemadn,
+ "ACI": "#",
+ })
+ setup_modify_ldif(schemadb,
+ setup_path("provision_schema_basedn_modify.ldif"), \
+ {"SCHEMADN": names.schemadn,
+ "NETBIOSNAME": names.netbiosname,
+ "DEFAULTSITE": DEFAULTSITE,
+ "CONFIGDN": names.configdn,
+ "SERVERDN": names.serverdn,
+ "PREFIXMAP_B64": b64encode(prefixmap)
+ })
+
+ data = load_schema(setup_path, schemadb, names.schemadn, names.netbiosname,
+ names.configdn, DEFAULTSITE, names.serverdn)
+ schemadb.add_ldif(data)
+ except:
+ schemadb.transaction_cancel()
+ raise
+ schemadb.transaction_commit()
if ldap_backend_type == "fedora-ds":
if ldap_backend_port is not None: