]> git.apps.os.sepia.ceph.com Git - ceph.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>
Thu, 2 Jul 2020 00:19:48 +0000 (17:19 -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>
(cherry picked from commit f451c43aca58945ca5d4646bf057e009deb0a787)

qa/tasks/cephfs/filesystem.py

index 2210fa970237b33a461b3792d16d8ba7c118556d..0005b0d6f94f624e9e40457f93778b501b5b07b7 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