diff options
author | Garming Sam <garming@catalyst.net.nz> | 2016-07-11 15:14:47 +1200 |
---|---|---|
committer | Garming Sam <garming@samba.org> | 2016-07-15 10:01:30 +0200 |
commit | 5361fc68436b4dcd8d1b7174daee27c78d3c7ade (patch) | |
tree | fe1e1e67f846e095f2a3de1a1fe2d85f41b8e8c3 | |
parent | 58acf513f93479d4b4c89e05a699e0bbd5320268 (diff) | |
download | samba-5361fc68436b4dcd8d1b7174daee27c78d3c7ade.tar.gz |
dbcheck: change argument to specify a partial --yes
Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
-rw-r--r-- | python/samba/dbchecker.py | 4 | ||||
-rw-r--r-- | python/samba/netcmd/dbcheck.py | 25 |
2 files changed, 25 insertions, 4 deletions
diff --git a/python/samba/dbchecker.py b/python/samba/dbchecker.py index ded4dc0a96c..f0c2217f683 100644 --- a/python/samba/dbchecker.py +++ b/python/samba/dbchecker.py @@ -280,14 +280,14 @@ systemFlags: -1946157056%s""" % (dn, guid_suffix), '''confirm a change with support for "all" ''' if not self.fix: return False - if self.quiet: - return self.yes if getattr(self, all_attr) == 'NONE': return False if getattr(self, all_attr) == 'ALL': forced = True else: forced = self.yes + if self.quiet: + return forced c = common.confirm(msg, forced=forced, allow_all=True) if c == 'ALL': setattr(self, all_attr, 'ALL') diff --git a/python/samba/netcmd/dbcheck.py b/python/samba/netcmd/dbcheck.py index 4cc0631bf76..2217366cc8d 100644 --- a/python/samba/netcmd/dbcheck.py +++ b/python/samba/netcmd/dbcheck.py @@ -38,6 +38,21 @@ class cmd_dbcheck(Command): "credopts": options.CredentialsOptionsDouble, } + def process_yes(option, opt, value, parser): + assert value is None + done = 0 + rargs = parser.rargs + if rargs: + arg = rargs[0] + if ((arg[:2] == "--" and len(arg) > 2) or + (arg[:1] == "-" and len(arg) > 1 and arg[1] != "-")): + setattr(parser.values, "yes", True) + else: + setattr(parser.values, "yes_rules", arg.split()) + del rargs[0] + else: + setattr(parser.values, "yes", True) + takes_args = ["DN?"] takes_options = [ @@ -45,7 +60,7 @@ class cmd_dbcheck(Command): help="Pass search scope that builds DN list. Options: SUB, ONE, BASE"), Option("--fix", dest="fix", default=False, action='store_true', help='Fix any errors found'), - Option("--yes", dest="yes", default=False, action='store_true', + Option("--yes", action='callback', callback=process_yes, help="don't confirm changes, just do them all as a single transaction"), Option("--cross-ncs", dest="cross_ncs", default=False, action='store_true', help="cross naming context boundaries"), @@ -65,7 +80,7 @@ class cmd_dbcheck(Command): cross_ncs=False, quiet=False, scope="SUB", credopts=None, sambaopts=None, versionopts=None, attrs=None, reindex=False, force_modules=False, - reset_well_known_acls=False): + reset_well_known_acls=False, yes_rules=[]): lp = sambaopts.get_loadparm() @@ -119,6 +134,12 @@ class cmd_dbcheck(Command): fix=fix, yes=yes, quiet=quiet, in_transaction=started_transaction, reset_well_known_acls=reset_well_known_acls) + for option in yes_rules: + if hasattr(chk, option): + setattr(chk, option, 'ALL') + else: + raise CommandError("Invalid fix rule %s" % option) + if reindex: self.outf.write("Re-indexing...\n") error_count = 0 |