]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
netcmd: domain: move leave command to domain/leave.py
authorRob van der Linde <rob@catalyst.net.nz>
Fri, 31 Mar 2023 00:05:07 +0000 (13:05 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 31 Mar 2023 07:25:32 +0000 (07:25 +0000)
Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/netcmd/domain/__init__.py
python/samba/netcmd/domain/leave.py [new file with mode: 0644]

index 778a3b523e5fefa06fe3a1d008bd467146b18399..76c8bdeb07ea11bbc7e8359a61632bfcbf71bd3f 100644 (file)
@@ -55,11 +55,8 @@ from samba.netcmd.fsmo import get_fsmo_roleowner
 from samba.netcmd.common import (NEVER_TIMESTAMP,
                                  timestamp_to_mins,
                                  timestamp_to_days)
-from samba.samba3 import param as s3param
 from samba import string_to_byte_array
 from samba.auth_util import system_session_unix
-from samba.net_s3 import Net as s3_Net
-from samba.param import default_path
 from samba import is_ad_dc_built
 
 from samba.dsdb import (
@@ -106,6 +103,7 @@ from .functional_prep import cmd_domain_functional_prep
 from .info import cmd_domain_info
 from .join import cmd_domain_join
 from .keytab import cmd_domain_export_keytab
+from .leave import cmd_domain_leave
 
 
 def level_to_string(level):
@@ -486,36 +484,6 @@ class cmd_domain_provision(Command):
             return None
 
 
-class cmd_domain_leave(Command):
-    """Cause a domain member to leave the joined domain."""
-
-    synopsis = "%prog [options]"
-
-    takes_optiongroups = {
-        "sambaopts": options.SambaOptions,
-        "versionopts": options.VersionOptions,
-        "credopts": options.CredentialsOptions,
-    }
-
-    takes_options = [
-        Option("--keep-account", action="store_true",
-               help="Disable the machine account instead of deleting it.")
-    ]
-
-    takes_args = []
-
-    def run(self, sambaopts=None, credopts=None, versionopts=None,
-            keep_account=False):
-        lp = sambaopts.get_loadparm()
-        creds = credopts.get_credentials(lp)
-
-        s3_lp = s3param.get_context()
-        smb_conf = lp.configfile if lp.configfile else default_path()
-        s3_lp.load(smb_conf)
-        s3_net = s3_Net(creds, s3_lp)
-        s3_net.leave(keep_account)
-
-
 class cmd_domain_level(Command):
     """Raise domain and forest function levels."""
 
diff --git a/python/samba/netcmd/domain/leave.py b/python/samba/netcmd/domain/leave.py
new file mode 100644 (file)
index 0000000..0d58360
--- /dev/null
@@ -0,0 +1,59 @@
+# domain management - domain leave
+#
+# Copyright Matthias Dieter Wallnoefer 2009
+# Copyright Andrew Kroeger 2009
+# Copyright Jelmer Vernooij 2007-2012
+# Copyright Giampaolo Lauria 2011
+# Copyright Matthieu Patou <mat@matws.net> 2011
+# Copyright Andrew Bartlett 2008-2015
+# Copyright Stefan Metzmacher 2012
+#
+# 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
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+import samba.getopt as options
+from samba.net_s3 import Net as s3_Net
+from samba.netcmd import Command, Option
+from samba.param import default_path
+from samba.samba3 import param as s3param
+
+
+class cmd_domain_leave(Command):
+    """Cause a domain member to leave the joined domain."""
+
+    synopsis = "%prog [options]"
+
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "versionopts": options.VersionOptions,
+        "credopts": options.CredentialsOptions,
+    }
+
+    takes_options = [
+        Option("--keep-account", action="store_true",
+               help="Disable the machine account instead of deleting it.")
+    ]
+
+    takes_args = []
+
+    def run(self, sambaopts=None, credopts=None, versionopts=None,
+            keep_account=False):
+        lp = sambaopts.get_loadparm()
+        creds = credopts.get_credentials(lp)
+
+        s3_lp = s3param.get_context()
+        smb_conf = lp.configfile if lp.configfile else default_path()
+        s3_lp.load(smb_conf)
+        s3_net = s3_Net(creds, s3_lp)
+        s3_net.leave(keep_account)