]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
teuthology/task: implement dump_ctx internal task 1208/head
authorNathan Cutler <ncutler@suse.com>
Fri, 14 Sep 2018 10:40:55 +0000 (12:40 +0200)
committerNathan Cutler <ncutler@suse.com>
Tue, 25 Sep 2018 10:19:43 +0000 (12:19 +0200)
This task is supposed to pretty-print the ctx and config parameters that are
passed to each task.

Signed-off-by: Nathan Cutler <ncutler@suse.com>
teuthology/task/dump_ctx.py [new file with mode: 0644]

diff --git a/teuthology/task/dump_ctx.py b/teuthology/task/dump_ctx.py
new file mode 100644 (file)
index 0000000..f2da22e
--- /dev/null
@@ -0,0 +1,19 @@
+import logging
+import pprint
+
+log = logging.getLogger(__name__)
+pp = pprint.PrettyPrinter(indent=4)
+
+def _pprint_me(thing, prefix):
+    return prefix + "\n" + pp.pformat(thing)
+
+def task(ctx, config):
+    """
+    Dump task context and config in teuthology log/output
+
+    The intended use case is didactic - to provide an easy way for newbies, who
+    are working on teuthology tasks for the first time, to find out what
+    is inside the ctx and config variables that are passed to each task.
+    """
+    log.info(_pprint_me(ctx, "Task context:"))
+    log.info(_pprint_me(config, "Task config:"))