From efebdba0119f3ac361448924258e263e8c9dbdff Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sun, 16 Jun 2013 13:36:19 -0700 Subject: [PATCH] ceph: do not print status to output file when talking to old mons The old cli would send the status message to stdout instead of stderr; we try to emulate that behavior when talking to old monitors because they send some useful data to outs instead of the data payload. However, when outputting to a *file*, the outs would still go to stdout. Maintain that so that, e.g., ceph mon getmap -o /tmp/foo doesn't prefix the monmap with 'got latest monmap\n'. Signed-off-by: Sage Weil --- src/ceph.in | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/ceph.in b/src/ceph.in index 69608021f9b23..c5ba2ce3d8aa0 100755 --- a/src/ceph.in +++ b/src/ceph.in @@ -1582,12 +1582,6 @@ def main(): if parsed_args.threshold: childargs.extend(['--threshold', parsed_args.threshold]) ret, outbuf, outs = send_command(target, childargs, inbuf) - # combine nonerror outbuf and outs; either may have cmd output - if ret == 0: - # old tool always added a newline - outbuf = outs + '\n' + outbuf - # clear outs so generic code below doesn't print it to stderr - outs = '' elif ret: if ret < 0: ret = -ret @@ -1613,7 +1607,11 @@ def main(): # this assumes outs never has useful command output, only status if outs: - print >> sys.stderr, prefix, outs + if compat and ret == 0: + # old cli/mon would send status string to stdout on non-error + print outs + else: + print >> sys.stderr, prefix, outs if (parsed_args.output_file): outf.write(outbuf) -- 2.39.5