From: Sage Weil Date: Sat, 15 Jun 2013 00:30:44 +0000 (-0700) Subject: ceph: add newline when using old monitors X-Git-Tag: v0.65~61 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c35c98d16d6c0c50c03b37fd91f22ae59593dfca;p=ceph.git ceph: add newline when using old monitors 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 Reviewed-by: Dan Mick --- diff --git a/src/ceph.in b/src/ceph.in index a0a1bb975ab..16155c9b311 100755 --- a/src/ceph.in +++ b/src/ceph.in @@ -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.