a3470f
From 0141f90b41ecd102e52a7e605858e25bd084a044 Mon Sep 17 00:00:00 2001
a3470f
From: Sunny Kumar <sunkumar@redhat.com>
a3470f
Date: Thu, 1 Feb 2018 12:08:06 +0530
a3470f
Subject: [PATCH 137/139] bitrot : improved cli report after bitrot operatoin
a3470f
a3470f
Improved cli report post bitrot opertaion as previously it was
a3470f
showing output "volume bitrot: success" for all the sucessfull
a3470f
bitrot operations (enable, disable or scrub options).
a3470f
a3470f
Upstream Patch : https://review.gluster.org/c/19344/
a3470f
a3470f
>BUG: 1539166
a3470f
>Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
a3470f
a3470f
BUG: 1517463
a3470f
a3470f
Change-Id: I0857e99f3956221a51cfd1b29a90e1038b90570f
a3470f
Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
a3470f
Reviewed-on: https://code.engineering.redhat.com/gerrit/129218
a3470f
Tested-by: RHGS Build Bot <nigelb@redhat.com>
a3470f
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
a3470f
---
a3470f
 cli/src/cli-rpc-ops.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++
a3470f
 1 file changed, 57 insertions(+)
a3470f
a3470f
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
a3470f
index b91400b..1bb01e8 100644
a3470f
--- a/cli/src/cli-rpc-ops.c
a3470f
+++ b/cli/src/cli-rpc-ops.c
a3470f
@@ -11922,6 +11922,10 @@ gf_cli_bitrot_cbk (struct rpc_req *req, struct iovec *iov,
a3470f
         int                  type                      = 0;
a3470f
         gf_cli_rsp           rsp                       = {0, };
a3470f
         dict_t               *dict                     = NULL;
a3470f
+        char                 *scrub_cmd                = NULL;
a3470f
+        char                 *volname                  = NULL;
a3470f
+        char                 *cmd_str                  = NULL;
a3470f
+        char                 *cmd_op                   = NULL;
a3470f
 
a3470f
         GF_ASSERT (myframe);
a3470f
 
a3470f
@@ -11977,6 +11981,22 @@ gf_cli_bitrot_cbk (struct rpc_req *req, struct iovec *iov,
a3470f
                 goto out;
a3470f
         }
a3470f
 
a3470f
+        /* Ignoring the error, as using dict val for cli output only */
a3470f
+        ret = dict_get_str (dict, "scrub-value", &scrub_cmd);
a3470f
+        if (ret)
a3470f
+                gf_log ("cli", GF_LOG_TRACE, "Failed to get scrub command");
a3470f
+
a3470f
+        ret = dict_get_str (dict, "volname", &volname);
a3470f
+        if (ret)
a3470f
+                gf_log ("cli", GF_LOG_TRACE, "failed to get volume name");
a3470f
+
a3470f
+        ret = dict_get_str (dict, "cmd-str", &cmd_str);
a3470f
+        if (ret)
a3470f
+                gf_log ("cli", GF_LOG_TRACE, "failed to get command string");
a3470f
+
a3470f
+        if (cmd_str)
a3470f
+                cmd_op = strrchr(cmd_str, ' ') + 1;
a3470f
+
a3470f
         if ((type == GF_BITROT_CMD_SCRUB_STATUS) &&
a3470f
              !(global_state->mode & GLUSTER_MODE_XML)) {
a3470f
                 ret = gf_cli_print_bitrot_scrub_status (dict);
a3470f
@@ -11987,6 +12007,43 @@ gf_cli_bitrot_cbk (struct rpc_req *req, struct iovec *iov,
a3470f
                 goto out;
a3470f
         }
a3470f
 
a3470f
+        switch (type) {
a3470f
+        case  GF_BITROT_OPTION_TYPE_ENABLE:
a3470f
+                cli_out("volume bitrot: success bitrot enabled "
a3470f
+                        "for volume %s", volname);
a3470f
+                ret = 0;
a3470f
+                goto out;
a3470f
+        case GF_BITROT_OPTION_TYPE_DISABLE:
a3470f
+                cli_out("volume bitrot: success bitrot disabled "
a3470f
+                        "for volume %s", volname);
a3470f
+                ret = 0;
a3470f
+                goto out;
a3470f
+        case GF_BITROT_CMD_SCRUB_ONDEMAND:
a3470f
+                cli_out("volume bitrot: scrubber started ondemand "
a3470f
+                        "for volume %s", volname);
a3470f
+                ret = 0;
a3470f
+                goto out;
a3470f
+        case GF_BITROT_OPTION_TYPE_SCRUB:
a3470f
+                if (!strncmp ("pause", scrub_cmd, strlen("pause")))
a3470f
+                        cli_out("volume bitrot: scrubber paused "
a3470f
+                                "for volume %s", volname);
a3470f
+                if (!strncmp ("resume", scrub_cmd, strlen("resume")))
a3470f
+                        cli_out("volume bitrot: scrubber resumed "
a3470f
+                                "for volume %s", volname);
a3470f
+                ret = 0;
a3470f
+                goto out;
a3470f
+        case GF_BITROT_OPTION_TYPE_SCRUB_FREQ:
a3470f
+                cli_out("volume bitrot: scrub-frequency is set to %s "
a3470f
+                        "successfully for volume %s", cmd_op, volname);
a3470f
+                ret = 0;
a3470f
+                goto out;
a3470f
+        case GF_BITROT_OPTION_TYPE_SCRUB_THROTTLE:
a3470f
+                cli_out("volume bitrot: scrub-throttle is set to %s "
a3470f
+                        "successfully for volume %s", cmd_op, volname);
a3470f
+                ret = 0;
a3470f
+                goto out;
a3470f
+        }
a3470f
+
a3470f
 xml_output:
a3470f
         if (global_state->mode & GLUSTER_MODE_XML) {
a3470f
                 ret = cli_xml_output_vol_profile (dict, rsp.op_ret,
a3470f
-- 
a3470f
1.8.3.1
a3470f