From c6bdd1b7b34fa3b01b3000ff6f2b4d0adb22d332 Mon Sep 17 00:00:00 2001 From: Nathan Cutler Date: Fri, 14 Sep 2018 12:40:55 +0200 Subject: [PATCH] teuthology/task: implement dump_ctx internal task This task is supposed to pretty-print the ctx and config parameters that are passed to each task. Signed-off-by: Nathan Cutler --- teuthology/task/dump_ctx.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 teuthology/task/dump_ctx.py diff --git a/teuthology/task/dump_ctx.py b/teuthology/task/dump_ctx.py new file mode 100644 index 0000000000..f2da22e121 --- /dev/null +++ b/teuthology/task/dump_ctx.py @@ -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:")) -- 2.39.5