expect_false ceph tell mon.zzz help
}
+function test_mon_stdin_stdout()
+{
+ echo foo | ceph config-key put test_key -i -
+ ceph config-key get test_key -o - | grep -c foo | grep -q 1
+}
+
function test_osd_tell_help_command()
{
ceph tell osd.1 help
MON_TESTS+=" mon_caps"
MON_TESTS+=" mon_cephdf_commands"
MON_TESTS+=" mon_tell_help_command"
+MON_TESTS+=" mon_stdin_stdout"
OSD_TESTS+=" osd_bench"
OSD_TESTS+=" osd_negative_filestore_merge_threshold"
parser.add_argument('-c', '--conf', dest='cephconf',
help='ceph configuration file')
parser.add_argument('-i', '--in-file', dest='input_file',
- help='input file')
+ help='input file, or "-" for stdin')
parser.add_argument('-o', '--out-file', dest='output_file',
- help='output file')
+ help='output file, or "-" for stdout')
parser.add_argument('--id', '--user', dest='client_id',
help='client id for authentication')
inbuf = b''
if parsed_args.input_file:
try:
- with open(parsed_args.input_file, 'rb') as f:
- inbuf = f.read()
+ if parsed_args.input_file == '-':
+ inbuf = sys.stdin.read()
+ else:
+ with open(parsed_args.input_file, 'rb') as f:
+ inbuf = f.read()
except Exception as e:
print('Can\'t open input file {0}: {1}'.format(parsed_args.input_file, e), file=sys.stderr)
return 1
# prepare output file, if any
if parsed_args.output_file:
try:
- outf = open(parsed_args.output_file, 'wb')
+ if parsed_args.output_file == '-':
+ outf = sys.stdout
+ else:
+ outf = open(parsed_args.output_file, 'wb')
except Exception as e:
print('Can\'t open output file {0}: {1}'.format(parsed_args.output_file, e), file=sys.stderr)
return 1
sys.stdout.flush()
- if parsed_args.output_file:
+ if parsed_args.output_file and parsed_args.output_file != '-':
outf.close()
if final_ret: