summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSage Weil <sage@inktank.com>2013-06-14 17:30:44 -0700
committerSage Weil <sage@inktank.com>2013-06-14 17:30:44 -0700
commitc35c98d16d6c0c50c03b37fd91f22ae59593dfca (patch)
tree5f740dcdb2bdacce4faa85752173f344e7449ab6
parentbb5fae4a5c7a130142d6d39f8f859fe60325ad3d (diff)
downloadceph-c35c98d16d6c0c50c03b37fd91f22ae59593dfca.tar.gz
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 <sage@inktank.com> Reviewed-by: Dan Mick <dan.mick@inktank.com>
-rwxr-xr-xsrc/ceph.in8
1 files changed, 6 insertions, 2 deletions
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.