summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorJunaid <junaid@gluster.com>2011-05-30 09:18:23 +0000
committerAnand Avati <avati@gluster.com>2011-06-13 22:38:54 -0700
commit1b8376013d2358a50bd7487e1abaa377d51ec4e6 (patch)
treebc3fa3d5b200bf159d1cc06ed172b945b50593fc /cli
parentf87ec977c2c6bf8c562c11ad72069648beb6d8cd (diff)
cli: Display a warning upon disabling quota.
Signed-off-by: Junaid <junaid@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 2912 (Display warning upon disable quota) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2912
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-cmd-parser.c50
-rw-r--r--cli/src/cli-cmd-volume.c11
2 files changed, 35 insertions, 26 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index d18336e7e..1ef8e4e3b 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -408,7 +408,6 @@ cli_cmd_quota_parse (const char **words, int wordcount, dict_t **options)
GF_ASSERT (options);
dict = dict_new ();
-
if (!dict)
goto out;
@@ -416,7 +415,6 @@ cli_cmd_quota_parse (const char **words, int wordcount, dict_t **options)
goto out;
volname = (char *)words[2];
-
if (!volname) {
ret = -1;
goto out;
@@ -444,7 +442,7 @@ cli_cmd_quota_parse (const char **words, int wordcount, dict_t **options)
}
ret = dict_set_str (dict, "volname", volname);
- if (ret)
+ if (ret < 0)
goto out;
w = str_getunamb (words[3], opwords);
@@ -455,11 +453,13 @@ cli_cmd_quota_parse (const char **words, int wordcount, dict_t **options)
if ((strcmp (w, "enable")) == 0 && wordcount == 4) {
type = GF_QUOTA_OPTION_TYPE_ENABLE;
+ ret = 0;
goto set_type;
}
if (strcmp (w, "disable") == 0 && wordcount == 4) {
type = GF_QUOTA_OPTION_TYPE_DISABLE;
+ ret = 0;
goto set_type;
}
@@ -493,7 +493,7 @@ cli_cmd_quota_parse (const char **words, int wordcount, dict_t **options)
}
ret = dict_set_str (dict, "limit", (char *) words[5]);
- if (ret)
+ if (ret < 0)
goto out;
goto set_type;
@@ -513,49 +513,49 @@ cli_cmd_quota_parse (const char **words, int wordcount, dict_t **options)
}
ret = dict_set_str (dict, "path", (char *) words[4]);
- if (ret)
+ if (ret < 0)
goto out;
goto set_type;
}
if (strcmp (w, "list") == 0) {
- if (wordcount < 4) {
- ret = -1;
- goto out;
- }
-
- type = GF_QUOTA_OPTION_TYPE_LIST;
+ if (wordcount < 4) {
+ ret = -1;
+ goto out;
+ }
- i = 4;
- while (i < wordcount) {
- snprintf (key, 20, "path%d", i-4);
+ type = GF_QUOTA_OPTION_TYPE_LIST;
- ret = dict_set_str (dict, key, (char *) words [i++]);
- if (ret < 0)
- goto out;
- }
+ i = 4;
+ while (i < wordcount) {
+ snprintf (key, 20, "path%d", i-4);
- ret = dict_set_int32 (dict, "count", i - 4);
+ ret = dict_set_str (dict, key, (char *) words [i++]);
if (ret < 0)
goto out;
+ }
+
+ ret = dict_set_int32 (dict, "count", i - 4);
+ if (ret < 0)
+ goto out;
- goto set_type;
+ goto set_type;
}
if (strcmp (w, "version") == 0) {
type = GF_QUOTA_OPTION_TYPE_VERSION;
-
- } else
+ } else {
GF_ASSERT (!"opword mismatch");
+ }
set_type:
ret = dict_set_int32 (dict, "type", type);
-
- if (ret)
+ if (ret < 0)
goto out;
+
*options = dict;
out:
- if (ret) {
+ if (ret < 0) {
if (dict)
dict_destroy (dict);
}
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index 467623f73..68ac79878 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -725,9 +725,13 @@ cli_cmd_quota_cbk (struct cli_state *state, struct cli_cmd_word *word,
int ret = 0;
int parse_err = 0;
+ int32_t type = 0;
rpc_clnt_procedure_t *proc = NULL;
call_frame_t *frame = NULL;
dict_t *options = NULL;
+ gf_answer_t answer = GF_ANSWER_NO;
+ const char *question = "Disabling quota will delete all the quota "
+ "configuration. Do you want to continue?";
proc = &cli_rpc_prog->proctable[GLUSTER_CLI_QUOTA];
if (proc == NULL) {
@@ -742,10 +746,15 @@ cli_cmd_quota_cbk (struct cli_state *state, struct cli_cmd_word *word,
}
ret = cli_cmd_quota_parse (words, wordcount, &options);
- if (ret) {
+ if (ret < 0) {
cli_usage_out (word->pattern);
parse_err = 1;
goto out;
+ } else if (dict_get_int32 (options, "type", &type) == 0 &&
+ type == GF_QUOTA_OPTION_TYPE_DISABLE) {
+ answer = cli_cmd_get_confirmation (state, question);
+ if (answer == GF_ANSWER_NO)
+ goto out;
}
if (proc->fn)