diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2012-02-27 03:50:37 +0100 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2012-02-27 05:25:04 +0100 |
commit | 47c62eeb68b95d0505936bf1e63b36f18ac1f2b2 (patch) | |
tree | 0a6391c1992120e978c00abb0faac27bbbc7913a /source4 | |
parent | 8008228b940bd8c28a7ae8ee1c2568cb2127f1d1 (diff) | |
download | samba-47c62eeb68b95d0505936bf1e63b36f18ac1f2b2.tar.gz samba-47c62eeb68b95d0505936bf1e63b36f18ac1f2b2.tar.bz2 samba-47c62eeb68b95d0505936bf1e63b36f18ac1f2b2.zip |
upgradehelpers: Simplify transaction handling.
Autobuild-User: Jelmer Vernooij <jelmer@samba.org>
Autobuild-Date: Mon Feb 27 05:25:04 CET 2012 on sn-devel-104
Diffstat (limited to 'source4')
-rwxr-xr-x | source4/scripting/python/samba/upgradehelpers.py | 49 |
1 files changed, 16 insertions, 33 deletions
diff --git a/source4/scripting/python/samba/upgradehelpers.py b/source4/scripting/python/samba/upgradehelpers.py index c6c9527e36..396e665294 100755 --- a/source4/scripting/python/samba/upgradehelpers.py +++ b/source4/scripting/python/samba/upgradehelpers.py @@ -74,11 +74,12 @@ class ProvisionLDB(object): self.hku = None self.hklm = None + def dbs(self): + return (self.sam, self.secrets, self.idmap, self.privilege) + def startTransactions(self): - self.sam.transaction_start() - self.secrets.transaction_start() - self.idmap.transaction_start() - self.privilege.transaction_start() + for db in self.dbs(): + db.transaction_start() # TO BE DONE # self.hkcr.transaction_start() # self.hkcu.transaction_start() @@ -87,26 +88,11 @@ class ProvisionLDB(object): def groupedRollback(self): ok = True - try: - self.sam.transaction_cancel() - except Exception: - ok = False - - try: - self.secrets.transaction_cancel() - except Exception: - ok = False - - try: - self.idmap.transaction_cancel() - except Exception: - ok = False - - try: - self.privilege.transaction_cancel() - except Exception: - ok = False - + for db in self.dbs(): + try: + db.transaction_cancel() + except Exception: + ok = False return ok # TO BE DONE # self.hkcr.transaction_cancel() @@ -116,10 +102,8 @@ class ProvisionLDB(object): def groupedCommit(self): try: - self.sam.transaction_prepare_commit() - self.secrets.transaction_prepare_commit() - self.idmap.transaction_prepare_commit() - self.privilege.transaction_prepare_commit() + for db in self.dbs(): + db.transaction_prepare_commit() except Exception: return self.groupedRollback() # TO BE DONE @@ -128,10 +112,8 @@ class ProvisionLDB(object): # self.hku.transaction_prepare_commit() # self.hklm.transaction_prepare_commit() try: - self.sam.transaction_commit() - self.secrets.transaction_commit() - self.idmap.transaction_commit() - self.privilege.transaction_commit() + for db in self.dbs(): + db.transaction_commit() except Exception: return self.groupedRollback() @@ -142,6 +124,7 @@ class ProvisionLDB(object): # self.hklm.transaction_commit() return True + def get_ldbs(paths, creds, session, lp): """Return LDB object mapped on most important databases @@ -534,7 +517,7 @@ def update_secrets(newsecrets_ldb, secrets_ldb, messagefunc): res2 = secrets_ldb.search(expression="(samaccountname=dns)", scope=SCOPE_SUBTREE, attrs=["dn"]) - if (len(res2) == 1): + if len(res2) == 1: messagefunc(SIMPLE, "Remove old dns account") secrets_ldb.delete(res2[0]["dn"]) |