]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Move teuthology-schedule's arg parsing to scripts/
authorZack Cerza <zack@cerza.org>
Tue, 8 Oct 2013 21:59:17 +0000 (16:59 -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/schedule.py [new file with mode: 0644]
setup.py
teuthology/run.py

diff --git a/scripts/schedule.py b/scripts/schedule.py
new file mode 100644 (file)
index 0000000..ab7d3e2
--- /dev/null
@@ -0,0 +1,99 @@
+import argparse
+
+from teuthology.run import config_file
+from teuthology.run import MergeConfig
+from teuthology.run import schedule
+
+
+def parse_args():
+    parser = argparse.ArgumentParser(
+        description='Schedule ceph integration tests')
+    parser.add_argument(
+        'config',
+        metavar='CONFFILE',
+        nargs='*',
+        type=config_file,
+        action=MergeConfig,
+        default={},
+        help='config file to read',
+    )
+    parser.add_argument(
+        '--name',
+        help='name of suite run the job is part of',
+    )
+    parser.add_argument(
+        '--last-in-suite',
+        action='store_true',
+        default=False,
+        help='mark the last job in a suite so suite post-processing can be ' +
+        'run',
+    )
+    parser.add_argument(
+        '--email',
+        help='where to send the results of a suite (only applies to the ' +
+        'last job in a suite)',
+    )
+    parser.add_argument(
+        '--timeout',
+        help='how many seconds to wait for jobs to finish before emailing ' +
+        'results (only applies to the last job in a suite',
+        type=int,
+    )
+    parser.add_argument(
+        '--description',
+        help='job description',
+    )
+    parser.add_argument(
+        '--owner',
+        help='job owner',
+    )
+    parser.add_argument(
+        '--delete',
+        metavar='JOBID',
+        type=int,
+        nargs='*',
+        help='list of jobs to remove from the queue',
+    )
+    parser.add_argument(
+        '-n', '--num',
+        default=1,
+        type=int,
+        help='number of times to run/queue the job'
+    )
+    parser.add_argument(
+        '-p', '--priority',
+        default=1000,
+        type=int,
+        help='beanstalk priority (lower is sooner)'
+    )
+    parser.add_argument(
+        '-v', '--verbose',
+        action='store_true',
+        default=False,
+        help='be more verbose',
+    )
+    parser.add_argument(
+        '-w', '--worker',
+        default='plana',
+        help='which worker to use (type of machine)',
+    )
+    parser.add_argument(
+        '-s', '--show',
+        metavar='JOBID',
+        type=int,
+        nargs='*',
+        help='output the contents of specified jobs in the queue',
+    )
+
+    return parser.parse_args()
+
+
+def main():
+    args = parse_args()
+    if not args.last_in_suite:
+        msg = '--email is only applicable to the last job in a suite'
+        assert not args.email, msg
+        msg = '--timeout is only applicable to the last job in a suite'
+        assert not args.timeout, msg
+    schedule(args)
+
index 53e3536575c8eb9916d67c6936ba3d9f70a69eb8..f97c9a220d8834d33b757b106988843a76e06bae 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -22,7 +22,7 @@ setup(
             'teuthology-ls = scripts.ls:main',
             'teuthology-worker = scripts.worker:main',
             'teuthology-lock = scripts.lock:main',
-            'teuthology-schedule = teuthology.run:schedule',
+            'teuthology-schedule = scripts.schedule:main',
             'teuthology-updatekeys = teuthology.lock:update_hostkeys',
             'teuthology-coverage = teuthology.coverage:analyze',
             'teuthology-results = teuthology.suite:results',
index f3a6458df170bcb3cd67c535d6d14e8e111bc5f9..4c5a71827d0569d4d4ea33d45675f81e9acb956a 100644 (file)
@@ -284,93 +284,7 @@ def main():
             sys.exit(1)
 
 
-def schedule():
-    parser = argparse.ArgumentParser(
-        description='Schedule ceph integration tests')
-    parser.add_argument(
-        'config',
-        metavar='CONFFILE',
-        nargs='*',
-        type=config_file,
-        action=MergeConfig,
-        default={},
-        help='config file to read',
-    )
-    parser.add_argument(
-        '--name',
-        help='name of suite run the job is part of',
-    )
-    parser.add_argument(
-        '--last-in-suite',
-        action='store_true',
-        default=False,
-        help='mark the last job in a suite so suite post-processing can be ' +
-        'run',
-    )
-    parser.add_argument(
-        '--email',
-        help='where to send the results of a suite (only applies to the ' +
-        'last job in a suite)',
-    )
-    parser.add_argument(
-        '--timeout',
-        help='how many seconds to wait for jobs to finish before emailing ' +
-        'results (only applies to the last job in a suite',
-        type=int,
-    )
-    parser.add_argument(
-        '--description',
-        help='job description',
-    )
-    parser.add_argument(
-        '--owner',
-        help='job owner',
-    )
-    parser.add_argument(
-        '--delete',
-        metavar='JOBID',
-        type=int,
-        nargs='*',
-        help='list of jobs to remove from the queue',
-    )
-    parser.add_argument(
-        '-n', '--num',
-        default=1,
-        type=int,
-        help='number of times to run/queue the job'
-    )
-    parser.add_argument(
-        '-p', '--priority',
-        default=1000,
-        type=int,
-        help='beanstalk priority (lower is sooner)'
-    )
-    parser.add_argument(
-        '-v', '--verbose',
-        action='store_true',
-        default=False,
-        help='be more verbose',
-    )
-    parser.add_argument(
-        '-w', '--worker',
-        default='plana',
-        help='which worker to use (type of machine)',
-    )
-    parser.add_argument(
-        '-s', '--show',
-        metavar='JOBID',
-        type=int,
-        nargs='*',
-        help='output the contents of specified jobs in the queue',
-    )
-
-    ctx = parser.parse_args()
-    if not ctx.last_in_suite:
-        msg = '--email is only applicable to the last job in a suite'
-        assert not ctx.email, msg
-        msg = '--timeout is only applicable to the last job in a suite'
-        assert not ctx.timeout, msg
-
+def schedule(ctx):
     from teuthology.misc import read_config, get_user
     if ctx.owner is None:
         ctx.owner = 'scheduled_{user}'.format(user=get_user())