From d236b01a8bf68b83c76ea1cfa8351833e19695f7 Mon Sep 17 00:00:00 2001 From: Gaurav Kumar Garg Date: Tue, 10 Mar 2015 15:04:59 +0530 Subject: cli/glusterd: cli command implementation for bitrot features CLI command for bitrot features. volume bitrot enable|disable Above command will enable/disable bitrot feature for particular volume. BUG: 1170075 Change-Id: Ie84002ef7f479a285688fdae99c7afa3e91b8b99 Signed-off-by: Gaurav Kumar Garg Signed-off-by: Anand nekkunti Signed-off-by: Dominic P Geevarghese Reviewed-on: http://review.gluster.org/9866 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- cli/src/cli-cmd-volume.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) (limited to 'cli/src/cli-cmd-volume.c') diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index 5632a9798bb..6c950da4e97 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -1299,6 +1299,58 @@ out: return ret; } +int +cli_cmd_bitrot_cbk (struct cli_state *state, struct cli_cmd_word *word, + const char **words, int wordcount) +{ + + int ret = -1; + int parse_err = 0; + call_frame_t *frame = NULL; + dict_t *options = NULL; + cli_local_t *local = NULL; + rpc_clnt_procedure_t *proc = NULL; + int sent = 0; + + ret = cli_cmd_bitrot_parse (words, wordcount, &options); + if (ret < 0) { + cli_usage_out (word->pattern); + parse_err = 1; + goto out; + } + + frame = create_frame (THIS, THIS->ctx->pool); + if (!frame) { + ret = -1; + goto out; + } + + proc = &cli_rpc_prog->proctable[GLUSTER_CLI_BITROT]; + if (proc == NULL) { + ret = -1; + goto out; + } + + CLI_LOCAL_INIT (local, words, frame, options); + + if (proc->fn) { + ret = proc->fn (frame, THIS, options); + } + +out: + if (ret) { + cli_cmd_sent_status_get (&sent); + if ((sent == 0) && (parse_err == 0)) + cli_err ("Bit rot command failed. Please check the cli " + "logs for more details"); + + } + + CLI_STACK_DESTROY (frame); + + return ret; +} + int cli_cmd_quota_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) @@ -2492,7 +2544,17 @@ struct cli_cmd volume_cmds[] = { }, {"volume get ", cli_cmd_volume_getopt_cbk, - "Get the value of the all options or given option for volume "}, + "Get the value of the all options or given option for volume " + }, + { "volume bitrot {enable|disable} |\n" + "volume bitrot {scrub-throttle frozen|lazy|normal" + "|aggressive} |\n" + "volume bitrot {scrub-frequency daily|weekly|biweekly" + "|monthly} |\n" + "volume bitrot {scrub pause|resume}", + cli_cmd_bitrot_cbk, + "Bitrot translator specific operations." + }, { NULL, NULL, NULL } }; -- cgit