]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph: add newline when using old monitors
authorSage Weil <sage@inktank.com>
Sat, 15 Jun 2013 00:30:44 +0000 (17:30 -0700)
committerSage Weil <sage@inktank.com>
Sat, 15 Jun 2013 00:30:44 +0000 (17:30 -0700)
The old tool would print a newline after outs, e.g. from 'ceph osd create'.
Do the same when we are talking to old monitors.  Also, put outs at the
top, not the bottom!

Tweak the json code to not add the newline again if we already did so
above.

Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Dan Mick <dan.mick@inktank.com>
src/ceph.in

index a0a1bb975abff5116cb69f72a69b36bdd00894ba..16155c9b31165fa99842324bfb36199bb435cb2e 100755 (executable)
@@ -1571,14 +1571,17 @@ def main():
 
         ret, outbuf, outs = json_command(target=target,
                                          prefix='get_command_descriptions')
+        compat = False
         if ret == -errno.EINVAL:
             # send command to old monitor or OSD
             if verbose:
                 print prefix, '{0} to old {1}'.format(' '.join(childargs), target[0])
+            compat = True
             ret, outbuf, outs = send_command(target, childargs, inbuf)
             # combine nonerror outbuf and outs; either may have cmd output
             if ret == 0:
-                outbuf += outs
+                # 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:
@@ -1616,7 +1619,8 @@ def main():
             # 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'):
+               parsed_args.output_format.startswith('json') and \
+               not compat:
                 sys.stdout.write('\n');
 
             # if we are prettifying things, normalize newlines.  sigh.