From fbfdd51a4dd39ddc805cf0d4b49313318bb679fd Mon Sep 17 00:00:00 2001 From: Dan Mick Date: Mon, 3 Jun 2013 12:32:14 -0700 Subject: [PATCH] ceph: backward-compatibility hack: blank line before JSON output 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 --- src/ceph | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ceph b/src/ceph index 08e2c748267..c34438ac4d8 100755 --- 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 -- 2.47.3