From 953f89d82f2c444719ba3150c9890c072a2e7fb3 Mon Sep 17 00:00:00 2001 From: Pranith K Date: Thu, 16 Dec 2010 01:24:33 +0000 Subject: glusterd,cli: print single error message on failure Signed-off-by: Pranith Kumar K Signed-off-by: Anand V. Avati BUG: 1922 (Volume not present wrong message displayed on command line) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1922 --- cli/src/cli-cmd-peer.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'cli/src/cli-cmd-peer.c') diff --git a/cli/src/cli-cmd-peer.c b/cli/src/cli-cmd-peer.c index dc361f539b6..ca89592d613 100644 --- a/cli/src/cli-cmd-peer.c +++ b/cli/src/cli-cmd-peer.c @@ -48,9 +48,12 @@ cli_cmd_peer_probe_cbk (struct cli_state *state, struct cli_cmd_word *word, rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; dict_t *dict = NULL; + int sent = 0; + int parse_error = 0; if (!(wordcount == 3)) { cli_usage_out (word->pattern); + parse_error = 1; goto out; } @@ -79,8 +82,11 @@ cli_cmd_peer_probe_cbk (struct cli_state *state, struct cli_cmd_word *word, } out: - if (ret) - cli_out ("Probe failed"); + if (ret) { + cli_cmd_sent_status_get (&sent); + if ((sent == 0) && (parse_error == 0)) + cli_out ("Peer probe failed"); + } return ret; } @@ -93,9 +99,12 @@ cli_cmd_peer_deprobe_cbk (struct cli_state *state, struct cli_cmd_word *word, rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; dict_t *dict = NULL; + int sent = 0; + int parse_error = 0; if (!(wordcount == 3) ) { cli_usage_out (word->pattern); + parse_error = 1; goto out; } @@ -122,6 +131,12 @@ cli_cmd_peer_deprobe_cbk (struct cli_state *state, struct cli_cmd_word *word, } out: + if (ret) { + cli_cmd_sent_status_get (&sent); + if ((sent == 0) && (parse_error == 0)) + cli_out ("Peer detach failed"); + } + return ret; } @@ -132,9 +147,12 @@ cli_cmd_peer_status_cbk (struct cli_state *state, struct cli_cmd_word *word, int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; + int sent = 0; + int parse_error = 0; if (wordcount != 2) { cli_usage_out (word->pattern); + parse_error = 1; goto out; } @@ -149,8 +167,11 @@ cli_cmd_peer_status_cbk (struct cli_state *state, struct cli_cmd_word *word, } out: - if (ret) - cli_out ("Command Execution failed"); + if (ret) { + cli_cmd_sent_status_get (&sent); + if ((sent == 0) && (parse_error == 0)) + cli_out ("Peer status failed"); + } return ret; } @@ -166,11 +187,10 @@ struct cli_cmd cli_probe_cmds[] = { { "peer status", cli_cmd_peer_status_cbk, "list status of peers"}, - - { "peer help", - cli_cmd_peer_help_cbk, - "Help command for peer "}, + { "peer help", + cli_cmd_peer_help_cbk, + "Help command for peer "}, { NULL, NULL, NULL } }; -- cgit