]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph: backward-compatibility hack: blank line before JSON output
authorDan Mick <dan.mick@inktank.com>
Mon, 3 Jun 2013 19:32:14 +0000 (12:32 -0700)
committerDan Mick <dan.mick@inktank.com>
Tue, 4 Jun 2013 04:07:17 +0000 (21:07 -0700)
Many JSON commands (osd dump, et. al.) used to print a status
line first before the actual output; this has been fixed, but there
are scripts/tools/etc. that expect it.  A simple compatibility hack
is to output a blank line, which won't confuse properly-written
JSON parsers, but will allow the tools-with-workarounds to continue
to work.

Signed-off-by: Dan Mick <dan.mick@inktank.com>
src/ceph

index 08e2c74826754768ff758e8365706ea8af873c9e..c34438ac4d80b70a3b2ec837d5c6535377b3c685 100755 (executable)
--- a/src/ceph
+++ b/src/ceph
@@ -1451,6 +1451,14 @@ def main():
         outf.write(outbuf)
         outf.close()
     else:
+        # hack: old code printed status line before many json outputs
+        # (osd dump, etc.) that consumers know to ignore.  Add blank line
+        # to satisfy consumers that skip the first line, but not annoy
+        # consumers that don't.
+        if parsed_args.output_format and \
+           parsed_args.output_format.startswith('json'):
+            sys.stdout.write('\n');
+
         sys.stdout.write(outbuf)
 
     # this assumes outs never has useful command output, only status