1 # Unix SMB/CIFS implementation.
2 # Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2011
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 """The main samba-tool command implementation."""
20 from samba import getopt as options
22 from samba.netcmd import SuperCommand
24 class cache_loader(dict):
26 We only load subcommand tools if they are actually used.
27 This significantly reduces the amount of time spent starting up
30 def __getitem__(self, attr):
31 item = dict.__getitem__(self, attr)
33 package = 'nettime' if attr == 'time' else attr
34 self[attr] = getattr(__import__('samba.netcmd.%s' % package,
35 fromlist=['cmd_%s' % attr]),
37 return dict.__getitem__(self, attr)
39 def get(self, attr, default=None):
47 yield (key, self[key])
50 class cmd_sambatool(SuperCommand):
51 """Main samba administration tool."""
53 takes_optiongroups = {
54 "versionopts": options.VersionOptions,
57 subcommands = cache_loader()
59 subcommands["computer"] = None
60 subcommands["dbcheck"] = None
61 subcommands["delegation"] = None
62 subcommands["dns"] = None
63 subcommands["domain"] = None
64 subcommands["drs"] = None
65 subcommands["dsacl"] = None
66 subcommands["forest"] = None
67 subcommands["fsmo"] = None
68 subcommands["gpo"] = None
69 subcommands["group"] = None
70 subcommands["ldapcmp"] = None
71 subcommands["ntacl"] = None
72 subcommands["rodc"] = None
73 subcommands["schema"] = None
74 subcommands["sites"] = None
75 subcommands["spn"] = None
76 subcommands["testparm"] = None
77 subcommands["time"] = None
78 subcommands["user"] = None
79 subcommands["ou"] = None
80 subcommands["processes"] = None
81 subcommands["visualize"] = None