From c784c79f1d3f42a6dc91f085984d8ac14b9a5995 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Tue, 8 Oct 2013 16:59:17 -0500 Subject: [PATCH] Move teuthology-schedule's arg parsing to scripts/ Signed-off-by: Zack Cerza --- scripts/schedule.py | 99 +++++++++++++++++++++++++++++++++++++++++++++ setup.py | 2 +- teuthology/run.py | 88 +--------------------------------------- 3 files changed, 101 insertions(+), 88 deletions(-) create mode 100644 scripts/schedule.py diff --git a/scripts/schedule.py b/scripts/schedule.py new file mode 100644 index 0000000000..ab7d3e2310 --- /dev/null +++ b/scripts/schedule.py @@ -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) + diff --git a/setup.py b/setup.py index 53e3536575..f97c9a220d 100644 --- 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', diff --git a/teuthology/run.py b/teuthology/run.py index f3a6458df1..4c5a71827d 100644 --- a/teuthology/run.py +++ b/teuthology/run.py @@ -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()) -- 2.39.5