diff options
author | Andrew Tridgell <tridge@samba.org> | 2011-07-12 11:05:43 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2011-07-13 12:51:05 +0200 |
commit | 0ab3086b46259a4627eabab93ebda41fd21408b0 (patch) | |
tree | 9e5956b408f2789fca5ada408f6cceecaa1aee3c | |
parent | 6bc1957a54ba2e3c73b0cf580c94e8055d451b03 (diff) | |
download | samba-0ab3086b46259a4627eabab93ebda41fd21408b0.tar.gz samba-0ab3086b46259a4627eabab93ebda41fd21408b0.tar.bz2 samba-0ab3086b46259a4627eabab93ebda41fd21408b0.zip |
dbcheck: added --reindex option
this allows you to force a reindex of the database
Pair-Programmed-With: Amitay Isaacs <amitay@gmail.com>
Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
-rw-r--r-- | source4/scripting/python/samba/dbchecker.py | 10 | ||||
-rw-r--r-- | source4/scripting/python/samba/netcmd/dbcheck.py | 13 |
2 files changed, 20 insertions, 3 deletions
diff --git a/source4/scripting/python/samba/dbchecker.py b/source4/scripting/python/samba/dbchecker.py index f89e2df878..1f250662ea 100644 --- a/source4/scripting/python/samba/dbchecker.py +++ b/source4/scripting/python/samba/dbchecker.py @@ -477,3 +477,13 @@ class dbcheck(object): self.fix_metadata(dn, att) return error_count + + ############################################### + # re-index the database + def reindex_database(self): + '''re-index the whole database''' + m = ldb.Message() + m.dn = ldb.Dn(self.samdb, "@ATTRIBUTES") + m['add'] = ldb.MessageElement('NONE', ldb.FLAG_MOD_ADD, 'force_reindex') + m['delete'] = ldb.MessageElement('NONE', ldb.FLAG_MOD_DELETE, 'force_reindex') + return self.do_modify(m, [], 're-indexed database', validate=False) diff --git a/source4/scripting/python/samba/netcmd/dbcheck.py b/source4/scripting/python/samba/netcmd/dbcheck.py index 203d447b12..823ec7a101 100644 --- a/source4/scripting/python/samba/netcmd/dbcheck.py +++ b/source4/scripting/python/samba/netcmd/dbcheck.py @@ -56,11 +56,12 @@ class cmd_dbcheck(Command): Option("--quiet", dest="quiet", action="store_true", default=False, help="don't print details of checking"), Option("--attrs", dest="attrs", default=None, help="list of attributes to check (space separated)"), + Option("--reindex", dest="reindex", default=False, action="store_true", help="force database re-index"), Option("-H", help="LDB URL for database or target server (defaults to local SAM database)", type=str), ] def run(self, DN=None, H=None, verbose=False, fix=False, yes=False, cross_ncs=False, quiet=False, - scope="SUB", credopts=None, sambaopts=None, versionopts=None, attrs=None): + scope="SUB", credopts=None, sambaopts=None, versionopts=None, attrs=None, reindex=False): lp = sambaopts.get_loadparm() @@ -101,11 +102,17 @@ class cmd_dbcheck(Command): samdb.transaction_start() chk = dbcheck(samdb, samdb_schema=samdb_schema, verbose=verbose, fix=fix, yes=yes, quiet=quiet) - error_count = chk.check_database(DN=DN, scope=search_scope, controls=controls, attrs=attrs) + + if reindex: + print("Re-indexing...") + error_count = 0 + if chk.reindex_database(): + print("completed re-index OK") + else: + error_count = chk.check_database(DN=DN, scope=search_scope, controls=controls, attrs=attrs) if yes and fix: samdb.transaction_commit() if error_count != 0: sys.exit(1) - |