2013-07-12 03:24:09 +00:00
|
|
|
import sys
|
|
|
|
import logging
|
|
|
|
|
|
|
|
from teuthology import run_tasks
|
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
2013-09-26 15:47:43 +00:00
|
|
|
|
2013-07-12 03:24:09 +00:00
|
|
|
def task(ctx, config):
|
|
|
|
"""
|
|
|
|
Sequentialize a group of tasks into one executable block
|
|
|
|
|
|
|
|
example:
|
|
|
|
- sequential:
|
|
|
|
- tasktest:
|
|
|
|
- tasktest:
|
|
|
|
|
2013-07-22 20:03:24 +00:00
|
|
|
You can also reference the job from elsewhere:
|
|
|
|
|
|
|
|
foo:
|
|
|
|
tasktest:
|
|
|
|
tasks:
|
|
|
|
- sequential:
|
|
|
|
- tasktest:
|
|
|
|
- foo
|
|
|
|
- tasktest:
|
|
|
|
|
|
|
|
That is, if the entry is not a dict, we will look it up in the top-level
|
|
|
|
config.
|
|
|
|
|
2013-07-12 03:24:09 +00:00
|
|
|
Sequential task and Parallel tasks can be nested.
|
|
|
|
"""
|
|
|
|
stack = []
|
|
|
|
try:
|
|
|
|
for entry in config:
|
2013-07-22 20:03:24 +00:00
|
|
|
if not isinstance(entry, dict):
|
|
|
|
entry = ctx.config.get(entry, {})
|
2013-07-12 03:24:09 +00:00
|
|
|
((taskname, confg),) = entry.iteritems()
|
|
|
|
log.info('In sequential, running task %s...' % taskname)
|
|
|
|
mgr = run_tasks.run_one_task(taskname, ctx=ctx, config=confg)
|
|
|
|
if hasattr(mgr, '__enter__'):
|
|
|
|
mgr.__enter__()
|
|
|
|
stack.append(mgr)
|
|
|
|
finally:
|
|
|
|
try:
|
|
|
|
exc_info = sys.exc_info()
|
|
|
|
while stack:
|
|
|
|
mgr = stack.pop()
|
2013-09-26 16:09:55 +00:00
|
|
|
mgr.__exit__(*exc_info)
|
2013-07-12 03:24:09 +00:00
|
|
|
finally:
|
|
|
|
del exc_info
|