]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
run: set up archive dir and logger output sooner
authorSage Weil <sage@inktank.com>
Thu, 29 Aug 2013 16:52:45 +0000 (09:52 -0700)
committerZack Cerza <zack@cerza.org>
Thu, 29 Aug 2013 20:03:30 +0000 (15:03 -0500)
Signed-off-by: Sage Weil <sage@inktank.com>
teuthology/run.py

index 653fb4c2a64ebed1e73e89d418e12af538e8f0e6..e7e50335e59c3bf2770831ed7278109a96f71c5c 100644 (file)
@@ -99,6 +99,31 @@ def main():
         level=loglevel,
         )
 
+    if ctx.owner is None:
+        from teuthology.misc import get_user
+        ctx.owner = get_user()
+
+    if ctx.archive is not None:
+        os.mkdir(ctx.archive)
+
+        handler = logging.FileHandler(
+            filename=os.path.join(ctx.archive, 'teuthology.log'),
+            )
+        formatter = logging.Formatter(
+            fmt='%(asctime)s.%(msecs)03d %(levelname)s:%(name)s:%(message)s',
+            datefmt='%Y-%m-%dT%H:%M:%S',
+            )
+        handler.setFormatter(formatter)
+        logging.getLogger().addHandler(handler)
+
+        with file(os.path.join(ctx.archive, 'pid'), 'w') as f:
+            f.write('%d' % os.getpid())
+
+        with file(os.path.join(ctx.archive, 'owner'), 'w') as f:
+            f.write(ctx.owner + '\n')
+
+        with file(os.path.join(ctx.archive, 'orig.config.yaml'), 'w') as f:
+            yaml.safe_dump(ctx.config, f, default_flow_style=False)
 
     if 'targets' in ctx.config and 'roles' in ctx.config:
         targets = len(ctx.config['targets'])
@@ -122,36 +147,11 @@ def main():
 
     ctx.summary = dict(success=True)
 
-    if ctx.owner is None:
-        from teuthology.misc import get_user
-        ctx.owner = get_user()
     ctx.summary['owner'] = ctx.owner
 
     if ctx.description is not None:
         ctx.summary['description'] = ctx.description
 
-    if ctx.archive is not None:
-        os.mkdir(ctx.archive)
-
-        handler = logging.FileHandler(
-            filename=os.path.join(ctx.archive, 'teuthology.log'),
-            )
-        formatter = logging.Formatter(
-            fmt='%(asctime)s.%(msecs)03d %(levelname)s:%(name)s:%(message)s',
-            datefmt='%Y-%m-%dT%H:%M:%S',
-            )
-        handler.setFormatter(formatter)
-        logging.getLogger().addHandler(handler)
-
-        with file(os.path.join(ctx.archive, 'pid'), 'w') as f:
-            f.write('%d' % os.getpid())
-
-        with file(os.path.join(ctx.archive, 'owner'), 'w') as f:
-            f.write(ctx.owner + '\n')
-
-        with file(os.path.join(ctx.archive, 'orig.config.yaml'), 'w') as f:
-            yaml.safe_dump(ctx.config, f, default_flow_style=False)
-
     for task in ctx.config['tasks']:
         assert 'kernel' not in task, \
             'kernel installation shouldn be a base-level item, not part of the tasks list'