samba-tool domain: Create a common set of options for provision/join/dcpromo
authorAndrew Bartlett <abartlet@samba.org>
Sun, 13 May 2018 23:02:46 +0000 (11:02 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 15 May 2018 19:13:26 +0000 (21:13 +0200)
These commands share much in common, the options should be in common as well.

Start with --targetdir.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
python/samba/netcmd/domain.py

index f3b5349ab5d67e8648cf9a80f47a6cdb38e5a738..85ce236298a918d715d3a5af0a275c00680654e9 100644 (file)
@@ -105,6 +105,11 @@ string_version_to_constant = {
     "2012_R2": DS_DOMAIN_FUNCTION_2012_R2,
 }
 
+common_provision_join_options = [
+    Option("--targetdir", metavar="DIR",
+           help="Set target directory (where to store provision)", type=str)
+]
+
 def get_testparm_var(testparm, smbconf, varname):
     errfile = open(os.devnull, 'w')
     p = subprocess.Popen([testparm, '-s', '-l',
@@ -246,8 +251,6 @@ class cmd_domain_provision(Command):
                 help="The initial nextRid value (only needed for upgrades).  Default is 1000."),
          Option("--partitions-only",
                 help="Configure Samba's partitions, but do not modify them (ie, join a BDC)", action="store_true"),
-         Option("--targetdir", type="string", metavar="DIR",
-                help="Set target directory"),
          Option("--use-rfc2307", action="store_true", help="Use AD to store posix attributes (default = no)"),
          Option("--plaintext-secrets", action="store_true",
                 help="Store secret/sensitive values as plain text on disk" +
@@ -286,6 +289,8 @@ class cmd_domain_provision(Command):
                default="auto")
     ]
 
+    takes_options.extend(common_provision_join_options)
+
     if os.getenv('TEST_LDAP', "no") == "yes":
         takes_options.extend(openldap_options)
 
@@ -566,7 +571,6 @@ class cmd_domain_dcpromo(Command):
     takes_options = [
         Option("--server", help="DC to join", type=str),
         Option("--site", help="site to join", type=str),
-        Option("--targetdir", help="where to store provision", type=str),
         Option("--domain-critical-only",
                help="only replicate critical domain objects",
                action="store_true"),
@@ -582,6 +586,8 @@ class cmd_domain_dcpromo(Command):
         Option("--verbose", help="Be verbose", action="store_true")
         ]
 
+    takes_options.extend(common_provision_join_options)
+
     ntvfs_options = [
          Option("--use-ntvfs", action="store_true", help="Use NTVFS for the fileserver (default = no)"),
     ]
@@ -645,7 +651,6 @@ class cmd_domain_join(Command):
     takes_options = [
         Option("--server", help="DC to join", type=str),
         Option("--site", help="site to join", type=str),
-        Option("--targetdir", help="where to store provision", type=str),
         Option("--parent-domain", help="parent domain to create subdomain under", type=str),
         Option("--domain-critical-only",
                help="only replicate critical domain objects",
@@ -671,6 +676,8 @@ class cmd_domain_join(Command):
         Option("--use-ntvfs", help="Use NTVFS for the fileserver (default = no)",
                action="store_true")
     ]
+    takes_options.extend(common_provision_join_options)
+
     if samba.is_ntvfs_fileserver_built():
         takes_options.extend(ntvfs_options)