From f451c43aca58945ca5d4646bf057e009deb0a787 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Sat, 13 Jun 2020 20:26:35 -0700 Subject: [PATCH] qa: quietly print json output from asok commands Pretty print output once. Use --format=json so the stdout on teuthology is not pretty printed, taking hundreds of lines. Signed-off-by: Patrick Donnelly --- qa/tasks/cephfs/filesystem.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/qa/tasks/cephfs/filesystem.py b/qa/tasks/cephfs/filesystem.py index 00da71cbed847..0f72c8ee7eb74 100644 --- a/qa/tasks/cephfs/filesystem.py +++ b/qa/tasks/cephfs/filesystem.py @@ -223,12 +223,16 @@ class CephCluster(object): def json_asok(self, command, service_type, service_id, timeout=None): if timeout is None: timeout = 15*60 + command.insert(0, '--format=json') proc = self.mon_manager.admin_socket(service_type, service_id, command, timeout=timeout) - response_data = proc.stdout.getvalue() - log.info("_json_asok output: {0}".format(response_data)) - if response_data.strip(): - return json.loads(response_data) + response_data = proc.stdout.getvalue().strip() + if len(response_data) > 0: + j = json.loads(response_data) + pretty = json.dumps(j, sort_keys=True, indent=2) + log.debug(f"_json_asok output\n{pretty}") + return j else: + log.debug(f"_json_asok output empty") return None -- 2.39.5