]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Move teuthology-nuke's arg parsing to scripts/
authorZack Cerza <zack@cerza.org>
Mon, 30 Sep 2013 21:31:44 +0000 (16:31 -0500)
committerZack Cerza <zack@cerza.org>
Fri, 11 Oct 2013 00:09:34 +0000 (19:09 -0500)
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
scripts/nuke.py [new file with mode: 0644]
setup.py
teuthology/nuke.py

diff --git a/scripts/nuke.py b/scripts/nuke.py
new file mode 100644 (file)
index 0000000..eae0b06
--- /dev/null
@@ -0,0 +1,83 @@
+import argparse
+from argparse import RawTextHelpFormatter
+import textwrap
+
+import teuthology.nuke
+
+
+def main():
+    teuthology.nuke.main(parse_args())
+
+
+def parse_args():
+    from teuthology.run import config_file
+    from teuthology.run import MergeConfig
+
+    parser = argparse.ArgumentParser(
+        description='Reset test machines',
+        epilog=textwrap.dedent('''
+        Examples:
+        teuthology-nuke -t target.yaml --unlock --owner user@host
+        teuthology-nuke -t target.yaml --pid 1234 --unlock --owner user@host \n
+        '''),
+        formatter_class=RawTextHelpFormatter)
+    parser.add_argument(
+        '-v', '--verbose',
+        action='store_true', default=None,
+        help='be more verbose'
+        )
+    parser.add_argument(
+        '-t', '--targets',
+        nargs='+',
+        type=config_file,
+        action=MergeConfig,
+        default={},
+        dest='config',
+        help='yaml config containing machines to nuke',
+        )
+    parser.add_argument(
+        '-a', '--archive',
+        metavar='DIR',
+        help='archive path for a job to kill and nuke',
+        )
+    parser.add_argument(
+        '--owner',
+        help='job owner',
+        )
+    parser.add_argument(
+        '-p',
+        '--pid',
+        type=int,
+        default=False,
+        help='pid of the process to be killed',
+        )
+    parser.add_argument(
+        '-r', '--reboot-all',
+        action='store_true',
+        default=False,
+        help='reboot all machines',
+        )
+    parser.add_argument(
+        '-s', '--synch-clocks',
+        action='store_true',
+        default=False,
+        help='synchronize clocks on all machines',
+        )
+    parser.add_argument(
+        '-u', '--unlock',
+        action='store_true',
+        default=False,
+        help='Unlock each successfully nuked machine, and output targets that'
+        'could not be nuked.'
+        )
+    parser.add_argument(
+        '-n', '--name',
+        metavar='NAME',
+        help='Name of run to cleanup'
+        )
+    parser.add_argument(
+        '-i', '--noipmi',
+        action='store_true', default=False,
+        help='Skip ipmi checking'
+    )
+    return parser.parse_args()
index b330b945d6ed11f815ec7f6c7827eb7045933ba7..e5bde8e8c2e61febde9d20351dc94f6528e202eb 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -17,7 +17,7 @@ setup(
     entry_points={
         'console_scripts': [
             'teuthology = teuthology.run:main',
-            'teuthology-nuke = teuthology.nuke:main',
+            'teuthology-nuke = scripts.nuke:main',
             'teuthology-suite = teuthology.suite:main',
             'teuthology-ls = teuthology.suite:ls',
             'teuthology-worker = teuthology.queue:worker',
index 7ad419c4a186f6fa440e52f388975ce0cc160386..b06ed245d3d38547b6ab2806d53a0c5c8296e572 100644 (file)
@@ -1,82 +1,5 @@
 import argparse
 import yaml
-import textwrap
-from argparse import RawTextHelpFormatter
-
-
-def parse_args():
-    from teuthology.run import config_file
-    from teuthology.run import MergeConfig
-
-    parser = argparse.ArgumentParser(
-        description='Reset test machines',
-        epilog=textwrap.dedent('''
-        Examples:
-        teuthology-nuke -t target.yaml --unlock --owner user@host
-        teuthology-nuke -t target.yaml --pid 1234 --unlock --owner user@host \n
-        '''),
-        formatter_class=RawTextHelpFormatter)
-    parser.add_argument(
-        '-v', '--verbose',
-        action='store_true', default=None,
-        help='be more verbose'
-        )
-    parser.add_argument(
-        '-t', '--targets',
-        nargs='+',
-        type=config_file,
-        action=MergeConfig,
-        default={},
-        dest='config',
-        help='yaml config containing machines to nuke',
-        )
-    parser.add_argument(
-        '-a', '--archive',
-        metavar='DIR',
-        help='archive path for a job to kill and nuke',
-        )
-    parser.add_argument(
-        '--owner',
-        help='job owner',
-        )
-    parser.add_argument(
-        '-p',
-        '--pid',
-        type=int,
-        default=False,
-        help='pid of the process to be killed',
-        )
-    parser.add_argument(
-        '-r', '--reboot-all',
-        action='store_true',
-        default=False,
-        help='reboot all machines',
-        )
-    parser.add_argument(
-        '-s', '--synch-clocks',
-        action='store_true',
-        default=False,
-        help='synchronize clocks on all machines',
-        )
-    parser.add_argument(
-        '-u', '--unlock',
-        action='store_true',
-        default=False,
-        help='Unlock each successfully nuked machine, and output targets that'
-        'could not be nuked.'
-        )
-    parser.add_argument(
-        '-n', '--name',
-        metavar='NAME',
-        help='Name of run to cleanup'
-        )
-    parser.add_argument(
-        '-i', '--noipmi',
-        action='store_true', default=False,
-        help='Skip ipmi checking'
-        )
-    args = parser.parse_args()
-    return args
 
 
 def shutdown_daemons(ctx, log):
@@ -341,10 +264,10 @@ def synch_clocks(remotes, log):
         proc.exitstatus.get()
 
 
-def main():
+def main(ctx):
     import gevent.monkey
     gevent.monkey.patch_all(dns=False)
-    from .orchestra import monkey
+    from teuthology.orchestra import monkey
     monkey.patch_all()
     from teuthology.run import config_file
     import os
@@ -353,15 +276,13 @@ def main():
 
     log = logging.getLogger(__name__)
 
-    ctx = parse_args()
-
     loglevel = logging.INFO
     if ctx.verbose:
         loglevel = logging.DEBUG
 
     logging.basicConfig(
         level=loglevel,
-        )
+    )
 
     info = {}
     if ctx.archive:
@@ -378,7 +299,6 @@ def main():
             ctx.owner = info.get('owner')
             if not ctx.owner:
                 ctx.owner = open(ctx.archive + '/owner').read().rstrip('\n')
-        ctx.name = info.get('name')
 
     from teuthology.misc import read_config
     read_config(ctx)