summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-cmd-peer.c36
-rw-r--r--cli/src/cli-cmd-volume.c211
-rw-r--r--cli/src/cli-cmd.c35
-rw-r--r--cli/src/cli-cmd.h1
-rw-r--r--cli/src/cli3_1-cops.c104
5 files changed, 277 insertions, 110 deletions
diff --git a/cli/src/cli-cmd-peer.c b/cli/src/cli-cmd-peer.c
index dc361f539..ca89592d6 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 }
};
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index 3f671a63a..0b6e2dd36 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -50,6 +50,8 @@ cli_cmd_volume_info_cbk (struct cli_state *state, struct cli_cmd_word *word,
call_frame_t *frame = NULL;
cli_cmd_volume_get_ctx_t ctx = {0,};
cli_local_t *local = NULL;
+ int sent = 0;
+ int parse_error = 0;
proc = &cli_rpc_prog->proctable[GF1_CLI_GET_VOLUME];
@@ -71,6 +73,7 @@ cli_cmd_volume_info_cbk (struct cli_state *state, struct cli_cmd_word *word,
proc = &cli_rpc_prog->proctable[GF1_CLI_GET_VOLUME];
} else {
cli_usage_out (word->pattern);
+ parse_error = 1;
return -1;
}
@@ -90,8 +93,12 @@ cli_cmd_volume_info_cbk (struct cli_state *state, struct cli_cmd_word *word,
}
out:
- if (ret)
- cli_out ("Getting Volume information failed!");
+ if (ret) {
+ cli_cmd_sent_status_get (&sent);
+ if ((sent == 0) && (parse_error == 0))
+ cli_out ("Getting Volume information failed!");
+ }
+
return ret;
}
@@ -104,10 +111,13 @@ cli_cmd_sync_volume_cbk (struct cli_state *state, struct cli_cmd_word *word,
rpc_clnt_procedure_t *proc = NULL;
call_frame_t *frame = NULL;
gf1_cli_sync_volume_req req = {0,};
+ int sent = 0;
+ int parse_error = 0;
if ((wordcount < 3) || (wordcount > 4)) {
- cli_usage_out (word->pattern);
- goto out;
+ cli_usage_out (word->pattern);
+ parse_error = 1;
+ goto out;
}
if ((wordcount == 3) || !strcmp(words[3], "all")) {
@@ -130,8 +140,11 @@ cli_cmd_sync_volume_cbk (struct cli_state *state, struct cli_cmd_word *word,
}
out:
- if (ret)
- cli_out ("Volume sync failed");
+ if (ret) {
+ cli_cmd_sent_status_get (&sent);
+ if ((sent == 0) && (parse_error == 0))
+ cli_out ("Volume sync failed");
+ }
return ret;
}
@@ -144,6 +157,8 @@ cli_cmd_volume_create_cbk (struct cli_state *state, struct cli_cmd_word *word,
rpc_clnt_procedure_t *proc = NULL;
call_frame_t *frame = NULL;
dict_t *options = NULL;
+ int sent = 0;
+ int parse_error = 0;
proc = &cli_rpc_prog->proctable[GF1_CLI_CREATE_VOLUME];
@@ -155,6 +170,7 @@ cli_cmd_volume_create_cbk (struct cli_state *state, struct cli_cmd_word *word,
if (ret) {
cli_usage_out (word->pattern);
+ parse_error = 1;
goto out;
}
@@ -165,6 +181,11 @@ cli_cmd_volume_create_cbk (struct cli_state *state, struct cli_cmd_word *word,
out:
if (options)
dict_unref (options);
+ if (ret) {
+ cli_cmd_sent_status_get (&sent);
+ if ((sent == 0) && (parse_error == 0))
+ cli_out ("Volume create failed");
+ }
return ret;
}
@@ -179,9 +200,12 @@ cli_cmd_volume_delete_cbk (struct cli_state *state, struct cli_cmd_word *word,
call_frame_t *frame = NULL;
char *volname = NULL;
gf_answer_t answer = GF_ANSWER_NO;
- const char *question = "Deleting volume will erase all information about the volume."
- "Do you want to continue?";
+ const char *question = NULL;
+ int sent = 0;
+ int parse_error = 0;
+ question = "Deleting volume will erase all information about the volume."
+ "Do you want to continue?";
proc = &cli_rpc_prog->proctable[GF1_CLI_DELETE_VOLUME];
frame = create_frame (THIS, THIS->ctx->pool);
@@ -190,6 +214,7 @@ cli_cmd_volume_delete_cbk (struct cli_state *state, struct cli_cmd_word *word,
if (wordcount != 3) {
cli_usage_out (word->pattern);
+ parse_error = 1;
goto out;
}
@@ -207,8 +232,11 @@ cli_cmd_volume_delete_cbk (struct cli_state *state, struct cli_cmd_word *word,
}
out:
- if (ret && volname)
- cli_out ("Deleting Volume %s failed", volname);
+ if (ret) {
+ cli_cmd_sent_status_get (&sent);
+ if ((sent == 0) && (parse_error == 0))
+ cli_out ("Volume delete failed");
+ }
return ret;
}
@@ -221,6 +249,8 @@ cli_cmd_volume_start_cbk (struct cli_state *state, struct cli_cmd_word *word,
rpc_clnt_procedure_t *proc = NULL;
call_frame_t *frame = NULL;
gf1_cli_start_vol_req req = {0,};
+ int sent = 0;
+ int parse_error = 0;
frame = create_frame (THIS, THIS->ctx->pool);
if (!frame)
@@ -228,6 +258,7 @@ cli_cmd_volume_start_cbk (struct cli_state *state, struct cli_cmd_word *word,
if (wordcount < 3 || wordcount > 4) {
cli_usage_out (word->pattern);
+ parse_error = 1;
goto out;
}
@@ -241,6 +272,7 @@ cli_cmd_volume_start_cbk (struct cli_state *state, struct cli_cmd_word *word,
} else {
ret = -1;
cli_usage_out (word->pattern);
+ parse_error = 1;
goto out;
}
}
@@ -252,8 +284,11 @@ cli_cmd_volume_start_cbk (struct cli_state *state, struct cli_cmd_word *word,
}
out:
- if (!proc && ret && req.volname)
- cli_out ("Starting Volume %s failed", req.volname);
+ if (ret) {
+ cli_cmd_sent_status_get (&sent);
+ if ((sent == 0) && (parse_error == 0))
+ cli_out ("Volume start failed");
+ }
return ret;
}
@@ -307,6 +342,8 @@ cli_cmd_volume_stop_cbk (struct cli_state *state, struct cli_cmd_word *word,
int flags = 0;
gf1_cli_stop_vol_req req = {0,};
gf_answer_t answer = GF_ANSWER_NO;
+ int sent = 0;
+ int parse_error = 0;
const char *question = "Stopping volume will make its data inaccessible. "
"Do you want to Continue?";
@@ -316,8 +353,9 @@ cli_cmd_volume_stop_cbk (struct cli_state *state, struct cli_cmd_word *word,
goto out;
if (wordcount < 3 || wordcount > 4) {
- cli_usage_out (word->pattern);
- goto out;
+ cli_usage_out (word->pattern);
+ parse_error = 1;
+ goto out;
}
req.volname = (char *)words[2];
@@ -330,6 +368,7 @@ cli_cmd_volume_stop_cbk (struct cli_state *state, struct cli_cmd_word *word,
} else {
ret = -1;
cli_usage_out (word->pattern);
+ parse_error = 1;
goto out;
}
}
@@ -349,8 +388,11 @@ cli_cmd_volume_stop_cbk (struct cli_state *state, struct cli_cmd_word *word,
}
out:
- if (!proc && ret && req.volname)
- cli_out ("Stopping Volume %s failed", req.volname);
+ if (ret) {
+ cli_cmd_sent_status_get (&sent);
+ if ((sent == 0) && (parse_error == 0))
+ cli_out ("Volume stop failed", req.volname);
+ }
return ret;
}
@@ -364,6 +406,8 @@ cli_cmd_volume_rename_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;
frame = create_frame (THIS, THIS->ctx->pool);
@@ -376,6 +420,7 @@ cli_cmd_volume_rename_cbk (struct cli_state *state, struct cli_cmd_word *word,
if (wordcount != 4) {
cli_usage_out (word->pattern);
+ parse_error = 1;
goto out;
}
@@ -396,11 +441,13 @@ cli_cmd_volume_rename_cbk (struct cli_state *state, struct cli_cmd_word *word,
}
out:
- if (!proc && ret) {
- if (dict)
- dict_destroy (dict);
- if (wordcount > 2)
- cli_out ("Renaming Volume %s failed", (char *)words[2]);
+ if (dict)
+ dict_destroy (dict);
+
+ if (ret) {
+ cli_cmd_sent_status_get (&sent);
+ if ((sent == 0) && (parse_error == 0))
+ cli_out ("Volume rename failed", (char *)words[2]);
}
return ret;
@@ -414,6 +461,8 @@ cli_cmd_volume_defrag_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;
frame = create_frame (THIS, THIS->ctx->pool);
if (!frame)
@@ -425,6 +474,7 @@ cli_cmd_volume_defrag_cbk (struct cli_state *state, struct cli_cmd_word *word,
if (wordcount != 4) {
cli_usage_out (word->pattern);
+ parse_error = 1;
goto out;
}
@@ -443,22 +493,24 @@ cli_cmd_volume_defrag_cbk (struct cli_state *state, struct cli_cmd_word *word,
}
out:
- if (!proc && ret) {
- if (dict)
- dict_destroy (dict);
+ if (dict)
+ dict_destroy (dict);
- if (wordcount > 2)
- cli_out ("Rebalance of Volume %s failed",
- (char *)words[2]);
+ if (ret) {
+ cli_cmd_sent_status_get (&sent);
+ if ((sent == 0) && (parse_error == 0))
+ cli_out ("Volume rebalance failed");
}
- return 0;
+ return ret;
}
int
-cli_cmd_volume_reset_cbk (struct cli_state *state, struct cli_cmd_word *word,
+cli_cmd_volume_reset_cbk (struct cli_state *state, struct cli_cmd_word *word,
const char **words, int wordcount)
{
+ int sent = 0;
+ int parse_error = 0;
int ret = -1;
rpc_clnt_procedure_t *proc = NULL;
@@ -475,6 +527,7 @@ cli_cmd_volume_reset_cbk (struct cli_state *state, struct cli_cmd_word *word,
if (ret) {
cli_usage_out (word->pattern);
+ parse_error = 1;
goto out;
}
@@ -483,9 +536,15 @@ cli_cmd_volume_reset_cbk (struct cli_state *state, struct cli_cmd_word *word,
}
out:
- if (options)
+ if (options)
dict_unref (options);
+ if (ret) {
+ cli_cmd_sent_status_get (&sent);
+ if ((sent == 0) && (parse_error == 0))
+ cli_out ("Volume reset failed");
+ }
+
return ret;
}
@@ -495,6 +554,8 @@ int
cli_cmd_volume_set_cbk (struct cli_state *state, struct cli_cmd_word *word,
const char **words, int wordcount)
{
+ int sent = 0;
+ int parse_error = 0;
int ret = -1;
rpc_clnt_procedure_t *proc = NULL;
@@ -511,6 +572,7 @@ cli_cmd_volume_set_cbk (struct cli_state *state, struct cli_cmd_word *word,
if (ret) {
cli_usage_out (word->pattern);
+ parse_error = 1;
goto out;
}
@@ -522,6 +584,12 @@ out:
if (options)
dict_unref (options);
+ if (ret) {
+ cli_cmd_sent_status_get (&sent);
+ if ((sent == 0) && (parse_error == 0))
+ cli_out ("Volume set failed");
+ }
+
return ret;
}
@@ -535,6 +603,8 @@ cli_cmd_volume_add_brick_cbk (struct cli_state *state,
rpc_clnt_procedure_t *proc = NULL;
call_frame_t *frame = NULL;
dict_t *options = NULL;
+ int sent = 0;
+ int parse_error = 0;
frame = create_frame (THIS, THIS->ctx->pool);
if (!frame)
@@ -544,6 +614,7 @@ cli_cmd_volume_add_brick_cbk (struct cli_state *state,
if (ret) {
cli_usage_out (word->pattern);
+ parse_error = 1;
goto out;
}
@@ -554,14 +625,15 @@ cli_cmd_volume_add_brick_cbk (struct cli_state *state,
}
out:
- if (!proc && ret) {
- if (wordcount > 2) {
- char *volname = (char *) words[2];
- cli_out ("Adding brick to Volume %s failed",volname );
- }
- }
if (options)
dict_unref (options);
+
+ if (ret) {
+ cli_cmd_sent_status_get (&sent);
+ if ((sent == 0) && (parse_error == 0))
+ cli_out ("Volume add-brick failed");
+ }
+
return ret;
}
@@ -576,6 +648,8 @@ cli_cmd_volume_remove_brick_cbk (struct cli_state *state,
call_frame_t *frame = NULL;
dict_t *options = NULL;
gf_answer_t answer = GF_ANSWER_NO;
+ int sent = 0;
+ int parse_error = 0;
const char *question = "Removing brick(s) can result in data loss. "
"Do you want to Continue?";
@@ -588,6 +662,7 @@ cli_cmd_volume_remove_brick_cbk (struct cli_state *state,
if (ret) {
cli_usage_out (word->pattern);
+ parse_error = 1;
goto out;
}
@@ -605,12 +680,12 @@ cli_cmd_volume_remove_brick_cbk (struct cli_state *state,
}
out:
- if (!proc && ret) {
- if (wordcount > 2) {
- char *volname = (char *) words[2];
- cli_out ("Removing brick from Volume %s failed",volname );
- }
+ if (ret) {
+ cli_cmd_sent_status_get (&sent);
+ if ((sent == 0) && (parse_error == 0))
+ cli_out ("Volume remove-brick failed");
}
+
if (options)
dict_unref (options);
return ret;
@@ -627,6 +702,8 @@ cli_cmd_volume_replace_brick_cbk (struct cli_state *state,
rpc_clnt_procedure_t *proc = NULL;
call_frame_t *frame = NULL;
dict_t *options = NULL;
+ int sent = 0;
+ int parse_error = 0;
proc = &cli_rpc_prog->proctable[GF1_CLI_REPLACE_BRICK];
@@ -638,6 +715,7 @@ cli_cmd_volume_replace_brick_cbk (struct cli_state *state,
if (ret) {
cli_usage_out (word->pattern);
+ parse_error = 1;
goto out;
}
@@ -646,14 +724,16 @@ cli_cmd_volume_replace_brick_cbk (struct cli_state *state,
}
out:
+ if (options)
+ dict_unref (options);
+
if (ret) {
- if (wordcount > 2) {
- char *volname = (char *) words[2];
- cli_out ("Replacing brick from Volume %s failed",volname );
- }
+ cli_cmd_sent_status_get (&sent);
+ if ((sent == 0) && (parse_error == 0))
+ cli_out ("Volume replace-brick failed");
}
- return ret;
+ return ret;
}
@@ -674,9 +754,12 @@ cli_cmd_log_filename_cbk (struct cli_state *state, struct cli_cmd_word *word,
rpc_clnt_procedure_t *proc = NULL;
call_frame_t *frame = NULL;
dict_t *options = NULL;
+ int sent = 0;
+ int parse_error = 0;
if (!((wordcount == 5) || (wordcount == 6))) {
cli_usage_out (word->pattern);
+ parse_error = 1;
goto out;
}
@@ -695,12 +778,15 @@ cli_cmd_log_filename_cbk (struct cli_state *state, struct cli_cmd_word *word,
}
out:
- if (ret)
- cli_out ("setting log filename failed");
-
if (options)
dict_destroy (options);
+ if (ret) {
+ cli_cmd_sent_status_get (&sent);
+ if ((sent == 0) && (parse_error == 0))
+ cli_out ("Volume log filename failed");
+ }
+
return ret;
}
@@ -713,9 +799,12 @@ cli_cmd_log_locate_cbk (struct cli_state *state, struct cli_cmd_word *word,
rpc_clnt_procedure_t *proc = NULL;
call_frame_t *frame = NULL;
dict_t *options = NULL;
+ int sent = 0;
+ int parse_error = 0;
if (!((wordcount == 4) || (wordcount == 5))) {
cli_usage_out (word->pattern);
+ parse_error = 1;
goto out;
}
@@ -734,12 +823,14 @@ cli_cmd_log_locate_cbk (struct cli_state *state, struct cli_cmd_word *word,
}
out:
- if (ret)
- cli_out ("getting log file location information failed");
-
if (options)
dict_destroy (options);
+ if (ret) {
+ cli_cmd_sent_status_get (&sent);
+ if ((sent == 0) && (parse_error == 0))
+ cli_out ("getting log file location information failed");
+ }
return ret;
}
@@ -752,9 +843,12 @@ cli_cmd_log_rotate_cbk (struct cli_state *state, struct cli_cmd_word *word,
rpc_clnt_procedure_t *proc = NULL;
call_frame_t *frame = NULL;
dict_t *options = NULL;
+ int sent = 0;
+ int parse_error = 0;
if (!((wordcount == 4) || (wordcount == 5))) {
cli_usage_out (word->pattern);
+ parse_error = 1;
goto out;
}
@@ -773,12 +867,15 @@ cli_cmd_log_rotate_cbk (struct cli_state *state, struct cli_cmd_word *word,
}
out:
- if (ret)
- cli_out ("log rotate failed");
-
if (options)
dict_destroy (options);
+ if (ret) {
+ cli_cmd_sent_status_get (&sent);
+ if ((sent == 0) && (parse_error == 0))
+ cli_out ("Volume log rotate failed");
+ }
+
return ret;
}
@@ -851,10 +948,10 @@ struct cli_cmd volume_cmds[] = {
{ "volume sync <HOSTNAME> [all|<VOLNAME>]",
cli_cmd_sync_volume_cbk,
"sync the volume information from a peer"},
-
+
{ "volume reset <VOLNAME> ",
cli_cmd_volume_reset_cbk,
- "reset all the reconfigured options"},
+ "reset all the reconfigured options"},
{ NULL, NULL, NULL }
};
diff --git a/cli/src/cli-cmd.c b/cli/src/cli-cmd.c
index f09c62106..2b9aea191 100644
--- a/cli/src/cli-cmd.c
+++ b/cli/src/cli-cmd.c
@@ -60,6 +60,38 @@ cli_cmd_needs_connection (struct cli_cmd_word *word)
}
int
+cli_cmd_status_reset (void)
+{
+ int ret = 0;
+
+ ret = cli_cmd_lock ();
+ {
+ if (ret == 0) {
+ cmd_sent = 0;
+ cmd_done = 0;
+ }
+ }
+ ret = cli_cmd_unlock ();
+ return ret;
+
+}
+
+int
+cli_cmd_sent_status_get (int *status)
+{
+ int ret = 0;
+ GF_ASSERT (status);
+
+ ret = cli_cmd_lock ();
+ {
+ if (ret == 0)
+ *status = cmd_sent;
+ }
+ ret = cli_cmd_unlock ();
+ return ret;
+}
+
+int
cli_cmd_process (struct cli_state *state, int argc, char **argv)
{
int ret = 0;
@@ -112,11 +144,10 @@ cli_cmd_process (struct cli_state *state, int argc, char **argv)
callback:
ret = word->cbkfn (state, word, (const char **)argv, argc);
-
+ (void) cli_cmd_status_reset ();
return ret;
}
-
int
cli_cmd_input_token_count (const char *text)
{
diff --git a/cli/src/cli-cmd.h b/cli/src/cli-cmd.h
index 1655c3a31..4daf7fae3 100644
--- a/cli/src/cli-cmd.h
+++ b/cli/src/cli-cmd.h
@@ -76,4 +76,5 @@ cli_cmd_submit (void *req, call_frame_t *frame,
gf_answer_t
cli_cmd_get_confirmation (struct cli_state *state, const char *question);
+int cli_cmd_sent_status_get (int *status);
#endif /* __CLI_CMD_H__ */
diff --git a/cli/src/cli3_1-cops.c b/cli/src/cli3_1-cops.c
index ba780e993..3003469cb 100644
--- a/cli/src/cli3_1-cops.c
+++ b/cli/src/cli3_1-cops.c
@@ -133,11 +133,10 @@ gf_cli3_1_probe_cbk (struct rpc_req *req, struct iovec *iov,
break;
default:
- cli_out ("Probe returned with unknown errno %d",
- rsp.op_errno);
+ cli_out ("Probe unsuccessful\nProbe returned "
+ "with unknown errno %d", rsp.op_errno);
break;
}
- cli_out ("Probe unsuccessful");
gf_log ("glusterd",GF_LOG_ERROR,"Probe failed with op_ret %d"
" and op_errno %d", rsp.op_ret, rsp.op_errno);
}
@@ -183,11 +182,11 @@ gf_cli3_1_deprobe_cbk (struct rpc_req *req, struct iovec *iov,
"cluster", rsp.hostname);
break;
default:
- cli_out ("Detach returned with unknown errno %d",
+ cli_out ("Detach unsuccessful\nDetach returned "
+ "with unknown errno %d",
rsp.op_errno);
break;
}
- cli_out ("Detach unsuccessful");
gf_log ("glusterd",GF_LOG_ERROR,"Detach failed with op_ret %d"
" and op_errno %d", rsp.op_ret, rsp.op_errno);
} else {
@@ -606,13 +605,13 @@ gf_cli3_1_create_volume_cbk (struct rpc_req *req, struct iovec *iov,
ret = dict_get_str (dict, "volname", &volname);
gf_log ("cli", GF_LOG_NORMAL, "Received resp to create volume");
- cli_out ("Creation of volume %s has been %s", volname,
- (rsp.op_ret) ? "unsuccessful":
- "successful. Please start the volume to "
- "access data.");
- if (rsp.op_ret && rsp.op_errstr)
- cli_out ("%s", rsp.op_errstr);
-
+ if (rsp.op_ret && strcmp (rsp.op_errstr, ""))
+ cli_out ("%s", rsp.op_errstr);
+ else
+ cli_out ("Creation of volume %s has been %s", volname,
+ (rsp.op_ret) ? "unsuccessful":
+ "successful. Please start the volume to "
+ "access data.");
ret = rsp.op_ret;
out:
@@ -657,9 +656,12 @@ gf_cli3_1_delete_volume_cbk (struct rpc_req *req, struct iovec *iov,
gf_log ("cli", GF_LOG_NORMAL, "Received resp to delete volume");
- cli_out ("Deleting volume %s has been %s", volname,
- (rsp.op_ret) ? "unsuccessful": "successful");
+ if (rsp.op_ret && strcmp (rsp.op_errstr, ""))
+ cli_out (rsp.op_errstr);
+ else
+ cli_out ("Deleting volume %s has been %s", volname,
+ (rsp.op_ret) ? "unsuccessful": "successful");
ret = rsp.op_ret;
out:
@@ -702,11 +704,12 @@ gf_cli3_1_start_volume_cbk (struct rpc_req *req, struct iovec *iov,
volname = local->u.start_vol.volname;
gf_log ("cli", GF_LOG_NORMAL, "Received resp to start volume");
- cli_out ("Starting volume %s has been %s", volname,
- (rsp.op_ret) ? "unsuccessful": "successful");
- if (rsp.op_ret && rsp.op_errstr)
+ if (rsp.op_ret && strcmp (rsp.op_errstr, ""))
cli_out ("%s", rsp.op_errstr);
+ else
+ cli_out ("Starting volume %s has been %s", volname,
+ (rsp.op_ret) ? "unsuccessful": "successful");
ret = rsp.op_ret;
@@ -750,12 +753,12 @@ gf_cli3_1_stop_volume_cbk (struct rpc_req *req, struct iovec *iov,
volname = local->u.start_vol.volname;
gf_log ("cli", GF_LOG_NORMAL, "Received resp to stop volume");
- cli_out ("Stopping volume %s has been %s", volname,
- (rsp.op_ret) ? "unsuccessful": "successful");
-
- if (rsp.op_ret && rsp.op_errstr)
- cli_out ("%s", rsp.op_errstr);
+ if (rsp.op_ret && strcmp (rsp.op_errstr, ""))
+ cli_out (rsp.op_errstr);
+ else
+ cli_out ("Stopping volume %s has been %s", volname,
+ (rsp.op_ret) ? "unsuccessful": "successful");
ret = rsp.op_ret;
out:
@@ -901,11 +904,12 @@ gf_cli3_1_reset_volume_cbk (struct rpc_req *req, struct iovec *iov,
}
gf_log ("cli", GF_LOG_NORMAL, "Received resp to reset");
- cli_out ("reset volume %s", (rsp.op_ret) ? "unsuccessful":
- "successful");
- if (rsp.op_ret && rsp.op_errstr)
+ if (rsp.op_ret && strcmp (rsp.op_errstr, ""))
cli_out ("%s", rsp.op_errstr);
+ else
+ cli_out ("reset volume %s", (rsp.op_ret) ? "unsuccessful":
+ "successful");
ret = rsp.op_ret;
@@ -917,7 +921,7 @@ out:
void
_cli_out_options (dict_t *this, char *key, data_t *value, void *count)
{
-
+
(*((int *) count))++;
cli_out ("%s - %s", key, value->data);
}
@@ -940,7 +944,7 @@ gf_cli3_1_set_volume_cbk (struct rpc_req *req, struct iovec *iov,
gf_log ("", GF_LOG_ERROR, "error");
goto out;
}
-
+
if (rsp.op_ret == 1) { // if the command was volume set <vol> history
if (!rsp.dict.dict_len) {
@@ -975,11 +979,12 @@ gf_cli3_1_set_volume_cbk (struct rpc_req *req, struct iovec *iov,
gf_log ("cli", GF_LOG_NORMAL, "Received resp to set");
- cli_out ("Set volume %s", (rsp.op_ret) ? "unsuccessful":
- "successful");
-
- if (rsp.op_ret && rsp.op_errstr)
+
+ if (rsp.op_ret && strcmp (rsp.op_errstr, ""))
cli_out ("%s", rsp.op_errstr);
+ else
+ cli_out ("Set volume %s", (rsp.op_ret) ? "unsuccessful":
+ "successful");
ret = rsp.op_ret;
@@ -1007,11 +1012,12 @@ gf_cli3_1_add_brick_cbk (struct rpc_req *req, struct iovec *iov,
gf_log ("cli", GF_LOG_NORMAL, "Received resp to add brick");
- cli_out ("Add Brick %s", (rsp.op_ret) ? "unsuccessful":
- "successful");
- if (rsp.op_ret && rsp.op_errstr)
+ if (rsp.op_ret && strcmp (rsp.op_errstr, ""))
cli_out ("%s", rsp.op_errstr);
+ else
+ cli_out ("Add Brick %s", (rsp.op_ret) ? "unsuccessful":
+ "successful");
ret = rsp.op_ret;
out:
@@ -1042,10 +1048,12 @@ gf_cli3_1_remove_brick_cbk (struct rpc_req *req, struct iovec *iov,
}
gf_log ("cli", GF_LOG_NORMAL, "Received resp to remove brick");
- cli_out ("Remove Brick %s", (rsp.op_ret) ? "unsuccessful":
- "successful");
- if (rsp.op_ret && rsp.op_errstr)
+
+ if (rsp.op_ret && strcmp (rsp.op_errstr, ""))
cli_out ("%s", rsp.op_errstr);
+ else
+ cli_out ("Remove Brick %s", (rsp.op_ret) ? "unsuccessful":
+ "successful");
ret = rsp.op_ret;
@@ -1199,8 +1207,12 @@ gf_cli3_1_log_filename_cbk (struct rpc_req *req, struct iovec *iov,
}
gf_log ("cli", GF_LOG_DEBUG, "Received resp to log filename");
- cli_out ("log filename : %s",
- (rsp.op_ret) ? "unsuccessful": "successful");
+
+ if (rsp.op_ret && strcmp (rsp.errstr, ""))
+ cli_out (rsp.errstr);
+ else
+ cli_out ("log filename : %s",
+ (rsp.op_ret) ? "unsuccessful": "successful");
ret = rsp.op_ret;
@@ -1254,7 +1266,12 @@ gf_cli3_1_log_rotate_cbk (struct rpc_req *req, struct iovec *iov,
}
gf_log ("cli", GF_LOG_DEBUG, "Received resp to log rotate");
- cli_out ("log rotate %s", (rsp.op_ret) ? "unsuccessful": "successful");
+
+ if (rsp.op_ret && strcmp (rsp.errstr, ""))
+ cli_out (rsp.errstr);
+ else
+ cli_out ("log rotate %s", (rsp.op_ret) ? "unsuccessful":
+ "successful");
ret = rsp.op_ret;
@@ -1281,11 +1298,12 @@ gf_cli3_1_sync_volume_cbk (struct rpc_req *req, struct iovec *iov,
}
gf_log ("cli", GF_LOG_DEBUG, "Received resp to sync");
- cli_out ("volume sync: %s",
- (rsp.op_ret) ? "unsuccessful": "successful");
- if (rsp.op_ret && rsp.op_errstr)
+ if (rsp.op_ret && strcmp (rsp.op_errstr, ""))
cli_out (rsp.op_errstr);
+ else
+ cli_out ("volume sync: %s",
+ (rsp.op_ret) ? "unsuccessful": "successful");
ret = rsp.op_ret;
out: