optional arguments:
-h, --help Show this help message and exit
-v, --verbose Be more verbose
+ -b <backend>, --queue-backend <backend>
+ Queue backend name, use prefix '@'
+ to append job config to the given
+ file path as yaml.
+ [default: beanstalk]
-n <name>, --name <name> Name of suite run the job is part of
-d <desc>, --description <desc> Job description
-o <owner>, --owner <owner> Job owner
Scheduler arguments:
--owner <owner> Job owner
+ -b <backend>, --queue-backend <backend>
+ Scheduler queue backend name
-e <email>, --email <email>
When tests finish or time out, send an email
here. May also be specified in ~/.teuthology.yaml
+import os
import yaml
import teuthology.beanstalk
if not name or name.isdigit():
raise ValueError("Please use a more descriptive value for --name")
job_config = build_config(args)
+ backend = args['--queue-backend']
if args['--dry-run']:
print('---\n' + yaml.safe_dump(job_config))
- else:
+ elif backend == 'beanstalk':
schedule_job(job_config, args['--num'], report_status)
+ elif backend.startswith('@'):
+ dump_job_to_file(backend.lstrip('@'), job_config, args['--num'])
+ else:
+ raise ValueError("Provided schedule backend '%s' is not supported. "
+ "Try 'beanstalk' or '@path-to-a-file" % backend)
def build_config(args):
if report_status:
report.try_push_job_info(job_config, dict(status='queued'))
num -= 1
+
+
+def dump_job_to_file(path, job_config, num=1):
+ """
+ Schedule a job.
+
+ :param job_config: The complete job dict
+ :param num: The number of times to schedule the job
+ :param path: The file path where the job config to append
+ """
+ num = int(num)
+ count_file_path = path + '.count'
+
+ jid = 0
+ if os.path.exists(count_file_path):
+ with open(count_file_path, 'r') as f:
+ jid=int(f.read() or '0')
+
+ with open(path, 'a') as f:
+ while num > 0:
+ jid += 1
+ job_config['job_id'] = str(jid)
+ job = yaml.safe_dump(job_config)
+ print('Job scheduled with name {name} and ID {jid}'.format(
+ name=job_config['name'], jid=jid))
+ f.write('---\n' + job)
+ num -= 1
+ with open(count_file_path, 'w') as f:
+ f.write(str(jid))
+