summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunny Kumar <sunkumar@redhat.com>2018-01-27 00:58:25 +0530
committerKotresh HR <khiremat@redhat.com>2018-02-01 03:29:18 +0000
commit5452943a3691d64a3fc76d1db96b1602b8f2c398 (patch)
tree9ce67d26113acc6df8d9e6db4fc8f97f31541d13
parent440a048f24b006c80af3d7bcd0a1f13fe3459d87 (diff)
bitrot : improved cli report after bitrot operatoin
Improved cli report post bitrot opertaion as previously it was showing output "volume bitrot: success" for all the sucessfull bitrot operations (enable, disable or scrub options). Change-Id: I0857e99f3956221a51cfd1b29a90e1038b90570f BUG: 1539166 Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
-rw-r--r--cli/src/cli-rpc-ops.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index a6efffc1207..c347c5c13e6 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -12056,6 +12056,10 @@ gf_cli_bitrot_cbk (struct rpc_req *req, struct iovec *iov,
int type = 0;
gf_cli_rsp rsp = {0, };
dict_t *dict = NULL;
+ char *scrub_cmd = NULL;
+ char *volname = NULL;
+ char *cmd_str = NULL;
+ char *cmd_op = NULL;
GF_ASSERT (myframe);
@@ -12111,6 +12115,22 @@ gf_cli_bitrot_cbk (struct rpc_req *req, struct iovec *iov,
goto out;
}
+ /* Ignoring the error, as using dict val for cli output only */
+ ret = dict_get_str (dict, "scrub-value", &scrub_cmd);
+ if (ret)
+ gf_log ("cli", GF_LOG_TRACE, "Failed to get scrub command");
+
+ ret = dict_get_str (dict, "volname", &volname);
+ if (ret)
+ gf_log ("cli", GF_LOG_TRACE, "failed to get volume name");
+
+ ret = dict_get_str (dict, "cmd-str", &cmd_str);
+ if (ret)
+ gf_log ("cli", GF_LOG_TRACE, "failed to get command string");
+
+ if (cmd_str)
+ cmd_op = strrchr(cmd_str, ' ') + 1;
+
if ((type == GF_BITROT_CMD_SCRUB_STATUS) &&
!(global_state->mode & GLUSTER_MODE_XML)) {
ret = gf_cli_print_bitrot_scrub_status (dict);
@@ -12121,6 +12141,43 @@ gf_cli_bitrot_cbk (struct rpc_req *req, struct iovec *iov,
goto out;
}
+ switch (type) {
+ case GF_BITROT_OPTION_TYPE_ENABLE:
+ cli_out("volume bitrot: success bitrot enabled "
+ "for volume %s", volname);
+ ret = 0;
+ goto out;
+ case GF_BITROT_OPTION_TYPE_DISABLE:
+ cli_out("volume bitrot: success bitrot disabled "
+ "for volume %s", volname);
+ ret = 0;
+ goto out;
+ case GF_BITROT_CMD_SCRUB_ONDEMAND:
+ cli_out("volume bitrot: scrubber started ondemand "
+ "for volume %s", volname);
+ ret = 0;
+ goto out;
+ case GF_BITROT_OPTION_TYPE_SCRUB:
+ if (!strncmp ("pause", scrub_cmd, strlen("pause")))
+ cli_out("volume bitrot: scrubber paused "
+ "for volume %s", volname);
+ if (!strncmp ("resume", scrub_cmd, strlen("resume")))
+ cli_out("volume bitrot: scrubber resumed "
+ "for volume %s", volname);
+ ret = 0;
+ goto out;
+ case GF_BITROT_OPTION_TYPE_SCRUB_FREQ:
+ cli_out("volume bitrot: scrub-frequency is set to %s "
+ "successfully for volume %s", cmd_op, volname);
+ ret = 0;
+ goto out;
+ case GF_BITROT_OPTION_TYPE_SCRUB_THROTTLE:
+ cli_out("volume bitrot: scrub-throttle is set to %s "
+ "successfully for volume %s", cmd_op, volname);
+ ret = 0;
+ goto out;
+ }
+
xml_output:
if (global_state->mode & GLUSTER_MODE_XML) {
ret = cli_xml_output_vol_profile (dict, rsp.op_ret,