From 22e14d7f8eb40838a0af8486abfbbd54364e9154 Mon Sep 17 00:00:00 2001 From: N Balachandran Date: Mon, 6 Nov 2017 10:00:54 +0530 Subject: cli: gluster help changes gluster cli help now shows only the top level help commands. gluster help will now show help commands for . > BUG: 1474768 > Signed-off-by: N Balachandran (cherry picked from commit 89dc54f50c9f800ca4446ea8fe736e4860588845) Change-Id: I263f53a0870d80ef4cfaad455fdaa47e2ac4423b BUG: 1509789 Signed-off-by: N Balachandran --- cli/src/cli-cmd-volume.c | 347 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 294 insertions(+), 53 deletions(-) (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 7bedd29306f..f9c16c3d792 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -36,7 +36,19 @@ extern rpc_clnt_prog_t cli_quotad_clnt; int cli_cmd_volume_help_cbk (struct cli_state *state, struct cli_cmd_word *in_word, - const char **words, int wordcount); + const char **words, int wordcount); + +int +cli_cmd_bitrot_help_cbk (struct cli_state *state, struct cli_cmd_word *in_word, + const char **words, int wordcount); + +int +cli_cmd_quota_help_cbk (struct cli_state *state, struct cli_cmd_word *in_word, + const char **words, int wordcount); + +int +cli_cmd_tier_help_cbk (struct cli_state *state, struct cli_cmd_word *in_word, + const char **words, int wordcount); int cli_cmd_volume_info_cbk (struct cli_state *state, struct cli_cmd_word *word, @@ -1293,9 +1305,12 @@ cli_cmd_volume_tier_cbk (struct cli_state *state, if (wordcount < 4) { - cli_usage_out (word->pattern); - if (wordcount == 3 && !strcmp(words[2], "help")) + if (wordcount == 3 && !strcmp(words[2], "help")) { + cli_cmd_tier_help_cbk (state, word, words, wordcount); ret = 0; + } else { + cli_usage_out (word->pattern); + } goto out; } @@ -1719,6 +1734,8 @@ out: return ret; } + + int cli_cmd_bitrot_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) @@ -1746,6 +1763,13 @@ cli_cmd_bitrot_cbk (struct cli_state *state, struct cli_cmd_word *word, goto out; } + if (ret == 1) { + /* this is 'volume bitrot help' */ + cli_cmd_bitrot_help_cbk (state, word, words, wordcount); + ret = 0; + goto out2; + } + frame = create_frame (THIS, THIS->ctx->pool); if (!frame) { ret = -1; @@ -1834,7 +1858,7 @@ out: #endif CLI_STACK_DESTROY (frame); - +out2: return ret; } @@ -1866,6 +1890,12 @@ cli_cmd_quota_cbk (struct cli_state *state, struct cli_cmd_word *word, } } else { ret = cli_cmd_quota_parse (words, wordcount, &options); + + if (ret == 1) { + cli_cmd_quota_help_cbk (state, word, words, wordcount); + ret = 0; + goto out; + } if (ret < 0) { cli_usage_out (word->pattern); parse_err = 1; @@ -3164,7 +3194,159 @@ out: return ret; } + +/* This is a bit of a hack to display the help. The current bitrot cmd + * format does not work well when registering the cmds. + * Ideally the should have been of the form + * gluster volume bitrot ... + */ + +struct cli_cmd bitrot_cmds[] = { + + {"volume bitrot help", + cli_cmd_bitrot_help_cbk, + "display help for volume bitrot commands" + }, + + {"volume bitrot {enable|disable}", + NULL, /*cli_cmd_bitrot_cbk,*/ + "Enable/disable bitrot for volume " + }, + + {"volume bitrot scrub-throttle {lazy|normal|aggressive}", + NULL, /*cli_cmd_bitrot_cbk,*/ + "Set the speed of the scrubber for volume " + }, + + {"volume bitrot scrub-frequency {hourly|daily|weekly|biweekly" + "|monthly}", + NULL, /*cli_cmd_bitrot_cbk,*/ + "Set the frequency of the scrubber for volume " + }, + + {"volume bitrot scrub {pause|resume|status|ondemand}", + NULL, /*cli_cmd_bitrot_cbk,*/ + "Pause/resume the scrubber for . Status displays the status of " + "the scrubber. ondemand starts the scrubber immediately." + }, + + {"volume bitrot {enable|disable}\n" + "volume bitrot scrub-throttle {lazy|normal|aggressive}\n" + "volume bitrot scrub-frequency {hourly|daily|weekly|biweekly" + "|monthly}\n" + "volume bitrot scrub {pause|resume|status|ondemand}", + cli_cmd_bitrot_cbk, + NULL + }, + + { NULL, NULL, NULL } +}; + + +struct cli_cmd quota_cmds[] = { + + /* Quota commands */ + {"volume quota help", + cli_cmd_quota_help_cbk, + "display help for volume quota commands" + }, + + {"volume quota {enable|disable|list [ ...]| " + "list-objects [ ...] | remove | remove-objects | " + "default-soft-limit }", + cli_cmd_quota_cbk, + "Enable/disable and configure quota for " + }, + + {"volume quota {limit-usage []}", + cli_cmd_quota_cbk, + "Set maximum size for for " + }, + + {"volume quota {limit-objects []}", + cli_cmd_quota_cbk, + "Set the maximum number of entries allowed in for " + }, + + {"volume quota {alert-time|soft-timeout|hard-timeout} {