From: Tommi Virtanen Date: Thu, 16 Jun 2011 20:01:09 +0000 (-0700) Subject: Move summary inside context. X-Git-Tag: v0.94.10~27^2^2~364^2~1718 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9353fcc9315eb76eed0202fd063f391ecd371fbd;p=ceph.git Move summary inside context. This will hopefully make run_tasks usable by tasks. The ceph task can't use it yet, because it has its yield inside the with nested statement. --- diff --git a/teuthology/run.py b/teuthology/run.py index c3b3926d3ef..dbd24cce37e 100644 --- a/teuthology/run.py +++ b/teuthology/run.py @@ -90,11 +90,12 @@ def main(): for rem, roles in zip(remotes, ctx.config['roles']): ctx.cluster.add(rem, roles) + ctx.summary = {} + + from teuthology.run_tasks import run_tasks try: - summary = {} - from teuthology.run_tasks import run_tasks - run_tasks(tasks=ctx.config['tasks'], ctx=ctx, summary=summary) + run_tasks(tasks=ctx.config['tasks'], ctx=ctx) finally: if ctx.archive is not None: with file(os.path.join(ctx.archive, 'summary.yaml'), 'w') as f: - yaml.safe_dump(summary, f, default_flow_style=False) + yaml.safe_dump(ctx.summary, f, default_flow_style=False) diff --git a/teuthology/run_tasks.py b/teuthology/run_tasks.py index 5baa97fda45..0c20d5d4114 100644 --- a/teuthology/run_tasks.py +++ b/teuthology/run_tasks.py @@ -13,7 +13,7 @@ def _run_one_task(taskname, **kwargs): fn = getattr(mod, subtask) return fn(**kwargs) -def run_tasks(tasks, ctx, summary): +def run_tasks(tasks, ctx): stack = [] try: for taskdict in tasks: @@ -27,7 +27,7 @@ def run_tasks(tasks, ctx, summary): manager.__enter__() stack.append(manager) except: - summary['success'] = False + ctx.summary['success'] = False log.exception('Saw exception from tasks') finally: try: @@ -38,7 +38,7 @@ def run_tasks(tasks, ctx, summary): try: suppress = manager.__exit__(*exc_info) except: - summary['success'] = False + ctx.summary['success'] = False log.exception('Manager failed: %s', manager) else: if suppress: @@ -51,5 +51,4 @@ def run_tasks(tasks, ctx, summary): finally: # be careful about cyclic references del exc_info - if 'success' not in summary: - summary['success'] = True + ctx.summary.setdefault('success', True)