Revert "samba-tool: moved takes_optiongroups definition to Command base class"
authorJelmer Vernooij <jelmer@samba.org>
Mon, 6 Feb 2012 15:33:38 +0000 (16:33 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Tue, 7 Feb 2012 00:11:08 +0000 (01:11 +0100)
This reverts commit f6fa8684896b8f3f9f8b7bd3742c99906973274c.

This keeps the main command class fairly slim, and makes it a bit
more obvious where the arguments to run() are coming from.

Conflicts:

source4/scripting/python/samba/netcmd/__init__.py
source4/scripting/python/samba/netcmd/domain.py
source4/scripting/python/samba/netcmd/gpo.py
source4/scripting/python/samba/netcmd/newuser.py
source4/scripting/python/samba/netcmd/testparm.py
source4/scripting/python/samba/netcmd/user.py
source4/scripting/python/samba/tests/samba_tool/__init__.py

17 files changed:
source4/scripting/python/samba/netcmd/__init__.py
source4/scripting/python/samba/netcmd/dbcheck.py
source4/scripting/python/samba/netcmd/delegation.py
source4/scripting/python/samba/netcmd/domain.py
source4/scripting/python/samba/netcmd/drs.py
source4/scripting/python/samba/netcmd/dsacl.py
source4/scripting/python/samba/netcmd/fsmo.py
source4/scripting/python/samba/netcmd/gpo.py
source4/scripting/python/samba/netcmd/group.py
source4/scripting/python/samba/netcmd/ldapcmp.py
source4/scripting/python/samba/netcmd/ntacl.py
source4/scripting/python/samba/netcmd/rodc.py
source4/scripting/python/samba/netcmd/spn.py
source4/scripting/python/samba/netcmd/testparm.py
source4/scripting/python/samba/netcmd/time.py
source4/scripting/python/samba/netcmd/user.py
source4/scripting/python/samba/netcmd/vampire.py

index 6d7ca43424e68a9a577eecd987d35b379957786b..f0cf7809c2994413260fb4c607249f7d029337cc 100644 (file)
@@ -3,7 +3,6 @@
 # Unix SMB/CIFS implementation.
 # Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2009-2011
 # Copyright (C) Theresa Halloran <theresahalloran@gmail.com> 2011
-# Copyright (C) Giampaolo Lauria <lauria2@yahoo.com> 2011
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -71,11 +70,7 @@ class Command(object):
     synopsis = None
     takes_args = []
     takes_options = []
-    takes_optiongroups = {
-        "sambaopts": options.SambaOptions,
-        "credopts": options.CredentialsOptions,
-        "versionopts": options.VersionOptions,
-        }
+    takes_optiongroups = {}
 
     def __init__(self, outf=sys.stdout, errf=sys.stderr):
         self.outf = outf
index 875b05950608e79ded390a5e4a1810a578c1f65b..72b2f9189aa6d0e1f8407a0dbe7b35f1abf4b327 100644 (file)
@@ -3,7 +3,6 @@
 # Samba4 AD database checker
 #
 # Copyright (C) Andrew Tridgell 2011
-# Copyright Giampaolo Lauria 2011 <lauria2@yahoo.com>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -35,6 +34,12 @@ class cmd_dbcheck(Command):
     """check local AD database for errors"""
     synopsis = "%prog [<DN>] [options]"
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "versionopts": options.VersionOptions,
+        "credopts": options.CredentialsOptionsDouble,
+    }
+
     takes_args = ["DN?"]
 
     takes_options = [
index 469579e58c9c0b2c7f1410a41670a465d28f4180..17901cd163f0eca72773687e240a1fe719c8b7a0 100644 (file)
@@ -5,7 +5,6 @@
 # Copyright Matthieu Patou mat@samba.org 2010
 # Copyright Stefan Metzmacher metze@samba.org 2011
 # Copyright Bjoern Baumbach bb@sernet.de 2011
-# Copyright Giampaolo Lauria 2011 <lauria2@yahoo.com>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -41,6 +40,12 @@ class cmd_delegation_show(Command):
 
     synopsis = "%prog <accountname> [options]"
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "credopts": options.CredentialsOptions,
+        "versionopts": options.VersionOptions,
+        }
+
     takes_args = ["accountname"]
 
     def run(self, accountname, credopts=None, sambaopts=None, versionopts=None):
@@ -80,6 +85,12 @@ class cmd_delegation_for_any_service(Command):
 
     synopsis = "%prog <accountname> [(on|off)] [options]"
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "credopts": options.CredentialsOptions,
+        "versionopts": options.VersionOptions,
+        }
+
     takes_args = ["accountname", "onoff"]
 
     def run(self, accountname, onoff, credopts=None, sambaopts=None, versionopts=None):
@@ -116,6 +127,12 @@ class cmd_delegation_for_any_protocol(Command):
 
     synopsis = "%prog <accountname> [(on|off)] [options]"
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "credopts": options.CredentialsOptions,
+        "versionopts": options.VersionOptions,
+        }
+
     takes_args = ["accountname", "onoff"]
 
     def run(self, accountname, onoff, credopts=None, sambaopts=None, versionopts=None):
@@ -152,6 +169,12 @@ class cmd_delegation_add_service(Command):
 
     synopsis = "%prog <accountname> <principal> [options]"
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "credopts": options.CredentialsOptions,
+        "versionopts": options.VersionOptions,
+        }
+
     takes_args = ["accountname", "principal"]
 
     def run(self, accountname, principal, credopts=None, sambaopts=None, versionopts=None):
@@ -189,6 +212,12 @@ class cmd_delegation_del_service(Command):
 
     synopsis = "%prog <accountname> <principal> [options]"
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "credopts": options.CredentialsOptions,
+        "versionopts": options.VersionOptions,
+        }
+
     takes_args = ["accountname", "principal"]
 
     def run(self, accountname, principal, credopts=None, sambaopts=None, versionopts=None):
index 176c4612dbad055971f085c69e1974999c423da5..664db18f5b2edfb943be4afe16d1d46691b433bd 100644 (file)
@@ -76,6 +76,12 @@ class cmd_domain_export_keytab(Command):
 
     synopsis = "%prog <keytab> [options]"
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "credopts": options.CredentialsOptions,
+        "versionopts": options.VersionOptions,
+        }
+
     takes_options = [
         Option("--principal", help="extract only this principal", type=str),
         ]
@@ -118,6 +124,12 @@ class cmd_domain_join(Command):
 
     synopsis = "%prog <dnsdomain> [DC|RODC|MEMBER|SUBDOMAIN] [options]"
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "versionopts": options.VersionOptions,
+        "credopts": options.CredentialsOptions,
+    }
+
     takes_options = [
         Option("--server", help="DC to join", type=str),
         Option("--site", help="site to join", type=str),
@@ -407,7 +419,7 @@ class cmd_domain_demote(Command):
             except ldb.LdbError, l:
                 pass
 
-        print "Demote successfull"
+        self.outf.write("Demote successfull\n")
 
 
 
@@ -416,6 +428,12 @@ class cmd_domain_level(Command):
 
     synopsis = "%prog (show|raise <options>) [options]"
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "credopts": options.CredentialsOptions,
+        "versionopts": options.VersionOptions,
+        }
+
     takes_options = [
         Option("-H", "--URL", help="LDB URL for database or target server", type=str,
                metavar="URL", dest="H"),
@@ -609,7 +627,6 @@ class cmd_domain_level(Command):
             raise CommandError("invalid argument: '%s' (choose from 'show', 'raise')" % subcommand)
 
 
-
 class cmd_domain_passwordsettings(Command):
     """Sets password settings
 
@@ -619,6 +636,12 @@ class cmd_domain_passwordsettings(Command):
 
     synopsis = "%prog (show|set <options>) [options]"
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "versionopts": options.VersionOptions,
+        "credopts": options.CredentialsOptions,
+        }
+
     takes_options = [
         Option("-H", "--URL", help="LDB URL for database or target server", type=str,
                metavar="URL", dest="H"),
index 0d93298e979c493ed1097b4013676bf4c007de6f..0b367e3cd13fcc5dd5a59b5d981151145a24ee6e 100644 (file)
@@ -3,7 +3,6 @@
 # implement samba_tool drs commands
 #
 # Copyright Andrew Tridgell 2010
-# Copyright Giampaolo Lauria 2011 <lauria2@yahoo.com>
 #
 # based on C implementation by Kamen Mazdrashki <kamen.mazdrashki@postpath.com>
 #
@@ -87,6 +86,12 @@ class cmd_drs_showrepl(Command):
 
     synopsis = "%prog [<DC>] [options]"
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "versionopts": options.VersionOptions,
+        "credopts": options.CredentialsOptions,
+    }
+
     takes_args = ["DC?"]
 
     def print_neighbour(self, n):
@@ -192,6 +197,12 @@ class cmd_drs_kcc(Command):
 
     synopsis = "%prog [<DC>] [options]"
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "versionopts": options.VersionOptions,
+        "credopts": options.CredentialsOptions,
+    }
+
     takes_args = ["DC?"]
 
     def run(self, DC=None, sambaopts=None,
@@ -255,6 +266,12 @@ class cmd_drs_replicate(Command):
 
     synopsis = "%prog <destinationDC> <sourceDC> <NC> [options]"
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "versionopts": options.VersionOptions,
+        "credopts": options.CredentialsOptions,
+    }
+
     takes_args = ["DEST_DC", "SOURCE_DC", "NC"]
 
     takes_options = [
@@ -325,6 +342,12 @@ class cmd_drs_bind(Command):
 
     synopsis = "%prog [<DC>] [options]"
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "versionopts": options.VersionOptions,
+        "credopts": options.CredentialsOptions,
+    }
+
     takes_args = ["DC?"]
 
     def run(self, DC=None, sambaopts=None,
@@ -418,6 +441,12 @@ class cmd_drs_options(Command):
 
     synopsis = "%prog [<DC>] [options]"
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "versionopts": options.VersionOptions,
+        "credopts": options.CredentialsOptions,
+    }
+
     takes_args = ["DC?"]
 
     takes_options = [
index b68af9ba396635d9bf8020c72caf338c310a3da4..a5d970369984e3f3c9b009cca892317bd5acb9fe 100644 (file)
@@ -3,7 +3,6 @@
 # Manipulate ACLs on directory objects
 #
 # Copyright (C) Nadezhda Ivanova <nivanova@samba.org> 2010
-# Copyright Giampaolo Lauria 2011 <lauria2@yahoo.com>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -53,6 +52,12 @@ class cmd_dsacl_set(Command):
     synopsis = "%prog [options]"
     car_help = """ The access control right to allow or deny """
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "credopts": options.CredentialsOptions,
+        "versionopts": options.VersionOptions,
+        }
+
     takes_options = [
         Option("-H", "--URL", help="LDB URL for database or target server",
                type=str, metavar="URL", dest="H"),
index 4449a306a9a46805fafa3f2f02cf44688556ab6d..958e5b8719b85828b629363c02db66bf67ae3e84 100644 (file)
@@ -4,7 +4,6 @@
 #
 # Copyright Nadezhda Ivanova 2009
 # Copyright Jelmer Vernooij 2009
-# Copyright Giampaolo Lauria 2011 <lauria2@yahoo.com>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -39,6 +38,12 @@ class cmd_fsmo_seize(Command):
 
     synopsis = "%prog [options]"
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "credopts": options.CredentialsOptions,
+        "versionopts": options.VersionOptions,
+        }
+
     takes_options = [
         Option("-H", "--URL", help="LDB URL for database or target server", type=str,
                metavar="URL", dest="H"),
index 398a95122dbb8394ca56db09cb1689c5ee758dd0..bd3480e053a73bc8f37277b491d6c43f7ce77d2d 100644 (file)
@@ -3,7 +3,6 @@
 # implement samba_tool gpo commands
 #
 # Copyright Andrew Tridgell 2010
-# Copyright Giampaolo Lauria 2011 <lauria2@yahoo.com>
 # Copyright Amitay Isaacs 2011 <amitay@gmail.com>
 #
 # based on C implementation by Guenther Deschner and Wilco Baan Hofman
@@ -241,6 +240,12 @@ class cmd_listall(Command):
 
     synopsis = "%prog [options]"
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "versionopts": options.VersionOptions,
+        "credopts": options.CredentialsOptions,
+    }
+
     takes_options = [
         Option("-H", "--URL", help="LDB URL for database or target server", type=str,
                metavar="URL", dest="H")
@@ -273,6 +278,11 @@ class cmd_list(Command):
     synopsis = "%prog <username> [options]"
 
     takes_args = ['username']
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "versionopts": options.VersionOptions,
+        "credopts": options.CredentialsOptions,
+    }
 
     takes_options = [
         Option("-H", "--URL", help="LDB URL for database or target server",
index 9c9add84330cb0500cf30a19db7b080f9110d527..0bbfde6f207424cb9eb27df75e9ae6ee2044f2c0 100644 (file)
@@ -5,7 +5,6 @@
 #
 # Based on the original in EJS:
 # Copyright Andrew Tridgell 2005
-# Copyright Giampaolo Lauria 2011 <lauria2@yahoo.com>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -69,6 +68,12 @@ Example2 adds a new distribution group to the local server.  The command is run
 
     synopsis = "%prog <groupname> [options]"
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "versionopts": options.VersionOptions,
+        "credopts": options.CredentialsOptions,
+    }
+
     takes_options = [
         Option("-H", "--URL", help="LDB URL for database or target server", type=str,
                metavar="URL", dest="H"),
@@ -131,6 +136,12 @@ Example2 deletes group Group2 from the local server.  The command is run under r
 
     synopsis = "%prog <groupname> [options]"
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "versionopts": options.VersionOptions,
+        "credopts": options.CredentialsOptions,
+    }
+
     takes_options = [
         Option("-H", "--URL", help="LDB URL for database or target server", type=str,
                metavar="URL", dest="H"),
@@ -173,6 +184,12 @@ Example2 shows how to add a single user account, User2, to the supergroup AD gro
 
     synopsis = "%prog <groupname> <listofmembers> [options]"
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "versionopts": options.VersionOptions,
+        "credopts": options.CredentialsOptions,
+    }
+
     takes_options = [
         Option("-H", "--URL", help="LDB URL for database or target server", type=str,
                metavar="URL", dest="H"),
@@ -217,6 +234,12 @@ Example2 shows how to remove a single user account, User2, from the supergroup A
 
     synopsis = "%prog <groupname> <listofmembers> [options]"
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "versionopts": options.VersionOptions,
+        "credopts": options.CredentialsOptions,
+    }
+
     takes_options = [
         Option("-H", "--URL", help="LDB URL for database or target server", type=str,
                metavar="URL", dest="H"),
index a6db4b11b0272f4ab7f23adc6b28d0bd40f12ee3..75708decd01e4f791a1932cdf4479640374a9a70 100755 (executable)
@@ -8,7 +8,6 @@
 # above partitions.
 
 # Copyright (C) Zahari Zahariev <zahari.zahariev@postpath.com> 2009, 2010
-# Copyright Giampaolo Lauria 2011 <lauria2@yahoo.com>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -863,6 +862,12 @@ class cmd_ldapcmp(Command):
         "credopts": options.CredentialsOptionsDouble,
     }
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "versionopts": options.VersionOptions,
+        "credopts": options.CredentialsOptionsDouble,
+    }
+
     takes_args = ["URL1", "URL2", "context1?", "context2?", "context3?"]
 
     takes_options = [
index 9f946139adca85a823953f43f0600f60e7da7f46..96d4c975c9f23983dd0ff0d4d3a1e9c86eedb310 100644 (file)
@@ -3,7 +3,6 @@
 # Manipulate file NT ACLs
 #
 # Copyright Matthieu Patou 2010 <mat@matws.net>
-# Copyright Giampaolo Lauria 2011 <lauria2@yahoo.com>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -44,6 +43,12 @@ class cmd_ntacl_set(Command):
 
     synopsis = "%prog <acl> <file> [options]"
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "credopts": options.CredentialsOptions,
+        "versionopts": options.VersionOptions,
+        }
+
     takes_options = [
         Option("--quiet", help="Be quiet", action="store_true"),
         Option("--xattr-backend", type="choice", help="xattr backend type (native fs or tdb)",
@@ -80,6 +85,12 @@ class cmd_ntacl_get(Command):
     """Set ACLs on a file"""
     synopsis = "%prog <file> [options]"
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "credopts": options.CredentialsOptions,
+        "versionopts": options.VersionOptions,
+        }
+
     takes_options = [
         Option("--as-sddl", help="Output ACL in the SDDL format", action="store_true"),
         Option("--xattr-backend", type="choice", help="xattr backend type (native fs or tdb)",
index b0500362ef480ae01bbb01ad2ac50438458329b5..e990262e80ff3dd4b4d475990e7bc61b1adf5d08 100644 (file)
@@ -3,7 +3,6 @@
 # rodc related commands
 #
 # Copyright Andrew Tridgell 2010
-# Copyright Giampaolo Lauria 2011 <lauria2@yahoo.com>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -33,6 +32,12 @@ class cmd_rodc_preload(Command):
 
     synopsis = "%prog (<SID>|<DN>|<accountname>) [options]"
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "versionopts": options.VersionOptions,
+        "credopts": options.CredentialsOptions,
+    }
+
     takes_options = [
         Option("--server", help="DC to use", type=str),
         ]
index 0f01a49fc4a96b137b9f99d45fe1ed0ef1edb791..3b9db7407b937c145a2b70afc3e971a314fae8db 100644 (file)
@@ -3,7 +3,6 @@
 # spn management
 #
 # Copyright Matthieu Patou mat@samba.org 2010
-# Copyright Giampaolo Lauria 2011 <lauria2@yahoo.com>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -38,6 +37,12 @@ class cmd_spn_list(Command):
 
     synopsis = "%prog <user> [options]"
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "credopts": options.CredentialsOptions,
+        "versionopts": options.VersionOptions,
+        }
+
     takes_args = ["user"]
 
     def run(self, user, credopts=None, sambaopts=None, versionopts=None):
@@ -75,6 +80,11 @@ class cmd_spn_add(Command):
 
     synopsis = "%prog <name> <user> [options]"
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "credopts": options.CredentialsOptions,
+        "versionopts": options.VersionOptions,
+        }
     takes_options = [
         Option("--force", help="Force the addition of the spn"\
                                " even it exists already", action="store_true"),
@@ -129,6 +139,12 @@ class cmd_spn_delete(Command):
 
     synopsis = "%prog <name> [user] [options]"
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "credopts": options.CredentialsOptions,
+        "versionopts": options.VersionOptions,
+        }
+
     takes_args = ["name", "user?"]
 
     def run(self, name, user=None, credopts=None, sambaopts=None, versionopts=None):
index 517196652b70917aaa1de981e44b122d7e52f778..8b45c646d4dcaa71d3187d1ead1075712ab105b6 100755 (executable)
@@ -4,7 +4,6 @@
 #   Unix SMB/CIFS implementation.
 #   Test validity of smb.conf
 #   Copyright (C) 2010-2011 Jelmer Vernooij <jelmer@samba.org>
-#   Copyright (C) Giampaolo Lauria 2011 <lauria2@yahoo.com>
 #
 # Based on the original in C:
 #   Copyright (C) Karl Auer 1993, 1994-1998
@@ -51,6 +50,11 @@ class cmd_testparm(Command):
         "versionopts": options.VersionOptions
     }
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "versionopts": options.VersionOptions
+    }
+
     takes_options = [
         Option("--section-name", type=str,
                help="Limit testparm to a named section"),
index 966799e7db714dff3191021a53cfe4fdc0791f5d..cc63849c0583148ed9783b3797968948755965fb 100644 (file)
@@ -3,7 +3,6 @@
 # time
 #
 # Copyright Jelmer Vernooij 2010 <jelmer@samba.org>
-# Copyright Giampaolo Lauria 2011 <lauria2@yahoo.com>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -44,6 +43,12 @@ Example2 return the date and time of the local server.
 """
     synopsis = "%prog [server-name] [options]"
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "credopts": options.CredentialsOptions,
+        "versionopts": options.VersionOptions,
+        }
+
     takes_args = ["server_name?"]
 
     def run(self, server_name=None, credopts=None, sambaopts=None, versionopts=None):
index 23c751525911c4a292f936da91d1f5f97e0e7bb6..a8cc2b840f4ca946219c1b753880ab655c5a2888 100644 (file)
@@ -4,7 +4,6 @@
 #
 # Copyright Jelmer Vernooij 2010 <jelmer@samba.org>
 # Copyright Theresa Halloran 2011 <theresahalloran@gmail.com>
-# Copyright Giampaolo Lauria 2011 <lauria2@yahoo.com>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 #
 
 import samba.getopt as options
-import sys, ldb
+import ldb
 from getpass import getpass
 from samba.auth import system_session
 from samba.samdb import SamDB
-from samba import gensec, generate_random_password
-from samba import dsdb
+from samba import (
+    dsdb,
+    gensec,
+    generate_random_password,
+    )
 from samba.net import Net
 
 from samba.netcmd import (
@@ -100,6 +102,12 @@ Example3 shows how to create a new user in the OrgUnit organizational unit.
 
     takes_args = ["username", "password?"]
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "credopts": options.CredentialsOptions,
+        "versionopts": options.VersionOptions,
+        }
+
     def run(self, username, password=None, credopts=None, sambaopts=None,
             versionopts=None, H=None, must_change_at_next_login=False, random_password=False,
             use_username_as_cn=False, userou=None, surname=None, given_name=None, initials=None,
@@ -163,6 +171,7 @@ sudo samba-tool user delete User2
 
 Example2 shows how to delete a user in the domain against the local server.   sudo is used so a user may run the command as root.
 
+<<<<<<< HEAD
 """
     synopsis = "%prog <username> [options]"
 
@@ -172,9 +181,13 @@ Example2 shows how to delete a user in the domain against the local server.   su
     ]
 
     takes_args = ["username"]
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "credopts": options.CredentialsOptions,
+        "versionopts": options.VersionOptions,
+        }
 
     def run(self, username, credopts=None, sambaopts=None, versionopts=None, H=None):
-
         lp = sambaopts.get_loadparm()
         creds = credopts.get_credentials(lp, fallback_machine=True)
 
@@ -197,6 +210,12 @@ class cmd_user_list(Command):
                metavar="URL", dest="H"),
         ]
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "credopts": options.CredentialsOptions,
+        "versionopts": options.VersionOptions,
+        }
+
     def run(self, sambaopts=None, credopts=None, versionopts=None, H=None):
         lp = sambaopts.get_loadparm()
         creds = credopts.get_credentials(lp, fallback_machine=True)
@@ -250,6 +269,13 @@ Example3 shows how to enable a user in the domain against a local LDAP server.
 """
     synopsis = "%prog (<username>|--filter <filter>) [options]"
 
+
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "versionopts": options.VersionOptions,
+        "credopts": options.CredentialsOptions,
+    }
+
     takes_options = [
         Option("-H", "--URL", help="LDB URL for database or target server", type=str,
                metavar="URL", dest="H"),
@@ -341,6 +367,12 @@ Example4 shows how to set the account expiration so that it will never expire.
 """
     synopsis = "%prog (<username>|--filter <filter>) [options]"
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "versionopts": options.VersionOptions,
+        "credopts": options.CredentialsOptions,
+    }
+
     takes_options = [
         Option("-H", "--URL", help="LDB URL for database or target server", type=str,
                metavar="URL", dest="H"),
@@ -442,6 +474,12 @@ Example3 shows how an administrator would reset TestUser3 user's password to pas
 """
     synopsis = "%prog (<username>|--filter <filter>) [options]"
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "versionopts": options.VersionOptions,
+        "credopts": options.CredentialsOptions,
+    }
+
     takes_options = [
         Option("-H", "--URL", help="LDB URL for database or target server", type=str,
                metavar="URL", dest="H"),
index 22a180a700cd34a05b00822216f2508d63c76407..32777cba3977519f78fca569ca800f82904015f8 100644 (file)
@@ -3,7 +3,6 @@
 # Vampire
 #
 # Copyright Jelmer Vernooij 2010 <jelmer@samba.org>
-# Copyright Giampaolo Lauria 2011 <lauria2@yahoo.com>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -35,6 +34,12 @@ class cmd_vampire(Command):
     """Join and synchronise a remote AD domain to the local server"""
     synopsis = "%prog [options] <domain>"
 
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "credopts": options.CredentialsOptions,
+        "versionopts": options.VersionOptions,
+        }
+
     takes_options = [
         Option("--target-dir", help="Target directory.", type=str),
         Option("--force", help="force run", action='store_true', default=False),