]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
qa: quietly print json output from asok commands
authorPatrick Donnelly <pdonnell@redhat.com>
Sun, 14 Jun 2020 03:26:35 +0000 (20:26 -0700)
committerPatrick Donnelly <pdonnell@redhat.com>
Wed, 24 Jun 2020 22:43:29 +0000 (15:43 -0700)
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 <pdonnell@redhat.com>
qa/tasks/cephfs/filesystem.py

index 00da71cbed847fea33c80dae5366ffd54aad20d7..0f72c8ee7eb74cde2361eca1c113eaa7684c8354 100644 (file)
@@ -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