]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph: do not print status to output file when talking to old mons
authorSage Weil <sage@inktank.com>
Sun, 16 Jun 2013 20:36:19 +0000 (13:36 -0700)
committerSage Weil <sage@inktank.com>
Sun, 16 Jun 2013 20:36:19 +0000 (13:36 -0700)
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 <sage@inktank.com>
src/ceph.in

index 69608021f9b23c6a19c36526e647185cb22f87f6..c5ba2ce3d8aa0d43e42d486f653d8eee18bc5c05 100755 (executable)
@@ -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)