]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Move summary inside context.
authorTommi Virtanen <tommi.virtanen@dreamhost.com>
Thu, 16 Jun 2011 20:01:09 +0000 (13:01 -0700)
committerTommi Virtanen <tommi.virtanen@dreamhost.com>
Thu, 16 Jun 2011 21:36:21 +0000 (14:36 -0700)
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.

teuthology/run.py
teuthology/run_tasks.py

index c3b3926d3efe94abd215a4532e1c3eedf7fcef29..dbd24cce37ee5b68c1800feddbd31fca4c9fa879 100644 (file)
@@ -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)
index 5baa97fda45dd12794fd67f253bab705b7afc2f3..0c20d5d4114444cf129b4dc7f14e5b377b85d4a0 100644 (file)
@@ -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)