summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorKrutika Dhananjay <kdhananj@redhat.com>2013-08-09 12:59:16 +0530
committerKrutika Dhananjay <kdhananj@redhat.com>2013-08-09 15:20:16 +0530
commitbd8e5775cf79e66dc5909f4a6a8df598f8691496 (patch)
tree3ae7629cb447a09fb2e44cd4de6cb9e13f90e0b6 /cli
parent325c3b192ef1d8f55201efa0d0cb9969b4f1e6c2 (diff)
glusterd: Clean up and fix glusterd_op_quota()
... and also fix cli logging In glusterd_op_quota(), * do not modify ret after going to 'out' as this causes the failure status (-1) to be overwritten, thereby causing the command to return 0 even on failure. * knock off additional labels like create_vol. * replace 'if' statements with 'switch case' statement. * delete only the 3 timeouts and the defaul-soft-limit, if present, from volinfo->dict, upon disablement of quota. Change-Id: If486a5373b66f2379d6d041a974d9b824fcb8518 Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-cmd-volume.c9
-rw-r--r--cli/src/cli-rpc-ops.c36
2 files changed, 15 insertions, 30 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index 21572edf..2702a44d 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -1014,6 +1014,7 @@ cli_cmd_quota_cbk (struct cli_state *state, struct cli_cmd_word *word,
dict_t *options = NULL;
gf_answer_t answer = GF_ANSWER_NO;
cli_local_t *local = NULL;
+ int sent = 0;
const char *question = "Disabling quota will delete all the quota "
"configuration. Do you want to continue?";
@@ -1048,13 +1049,15 @@ cli_cmd_quota_cbk (struct cli_state *state, struct cli_cmd_word *word,
ret = proc->fn (frame, THIS, options);
out:
- if (ret && parse_err == 0)
- cli_out ("Quota command failed");
+ if (ret) {
+ cli_cmd_sent_status_get (&sent);
+ if (sent == 0 && parse_err == 0)
+ cli_out ("Quota command failed");
+ }
CLI_STACK_DESTROY (frame);
return ret;
-
}
int
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index a1977397..ae31ddef 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -2687,7 +2687,6 @@ gf_cli_quota_cbk (struct rpc_req *req, struct iovec *iov,
char *volname = NULL;
char *limit_list = NULL;
int32_t type = 0;
- char msg[5120] = {0,};
call_frame_t *frame = NULL;
uint32_t op_version = 1;
char *default_sl = NULL;
@@ -2706,15 +2705,14 @@ gf_cli_quota_cbk (struct rpc_req *req, struct iovec *iov,
goto out;
}
- if (rsp.op_ret &&
- strcmp (rsp.op_errstr, "") == 0) {
- snprintf (msg, sizeof (msg), "command unsuccessful %s",
- rsp.op_errstr);
+ if (rsp.op_ret && strcmp (rsp.op_errstr, "") == 0) {
+ cli_err ("quota command : failed");
if (global_state->mode & GLUSTER_MODE_XML)
goto xml_output;
goto out;
- }
+ } else if (strcmp (rsp.op_errstr, ""))
+ cli_err ("quota command failed : %s", rsp.op_errstr);
if (rsp.dict.dict_len) {
/* Unserialize the dictionary */
@@ -2731,6 +2729,8 @@ gf_cli_quota_cbk (struct rpc_req *req, struct iovec *iov,
}
}
+ gf_log ("cli", GF_LOG_DEBUG, "Received resp to quota command");
+
ret = dict_get_str (dict, "volname", &volname);
if (ret)
gf_log (frame->this->name, GF_LOG_TRACE,
@@ -2789,25 +2789,11 @@ gf_cli_quota_cbk (struct rpc_req *req, struct iovec *iov,
gf_cli_quota_list_run_crawler (volname, limit_list, dict, count,
rsp.op_errstr, op_version,
default_sl, entry_count);
- if (rsp.op_errstr)
- snprintf (msg, sizeof (msg)-1, "%s", rsp.op_errstr);
- }
-
- gf_log ("cli", GF_LOG_DEBUG, "Received resp to quota command");
-
- if (rsp.op_errstr) {
- snprintf (msg, sizeof (msg)-1, "%s", rsp.op_errstr);
- } else {
- if (!rsp.op_ret)
- snprintf (msg, sizeof (msg)-1, "Quota command "
- "successful");
- else
- snprintf (msg, sizeof (msg)-1, "Quota command failed");
}
xml_output:
if (global_state->mode & GLUSTER_MODE_XML) {
- ret = cli_xml_output_str ("volQuota", msg, rsp.op_ret,
+ ret = cli_xml_output_str ("volQuota", NULL, rsp.op_ret,
rsp.op_errno, rsp.op_errstr);
if (ret)
gf_log ("cli", GF_LOG_ERROR,
@@ -2815,12 +2801,8 @@ xml_output:
goto out;
}
- if (strlen (msg) > 0) {
- if (rsp.op_ret)
- cli_err ("%s", msg);
- else
- cli_out ("%s", msg);
- }
+ if (!rsp.op_ret && type != GF_QUOTA_OPTION_TYPE_LIST)
+ cli_out ("volume quota : success");
ret = rsp.op_ret;
out: