summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorJunaid <junaid@gluster.com>2011-04-11 01:15:53 +0000
committerAnand Avati <avati@gluster.com>2011-04-11 05:43:57 -0700
commitf5625e628f1959331eed85082cb6bfdc324db3c2 (patch)
tree3c94c87ac97358e571c2e785b5af2dbb301e5f4f /cli
parent974be663a9113d4aed684dce00f5288669d511e8 (diff)
cli: Validating the cli quota options.
Signed-off-by: Junaid <junaid@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 2612 (quota limit-set not in line with help) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2612
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-cmd-parser.c16
-rw-r--r--cli/src/cli-cmd-volume.c2
2 files changed, 11 insertions, 7 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index 300091d97..c476638ba 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -373,6 +373,7 @@ cli_cmd_quota_parse (const char **words, int wordcount, dict_t **options)
int ret = -1;
int i = 0;
char key[20] = {0, };
+ uint64_t value = 0;
gf_quota_type type = GF_QUOTA_OPTION_TYPE_NONE;
GF_ASSERT (words);
@@ -418,17 +419,16 @@ cli_cmd_quota_parse (const char **words, int wordcount, dict_t **options)
}
ret = dict_set_str (dict, "volname", volname);
-
if (ret)
goto out;
- if ((strcasecmp (words[3], "enable")) == 0) {
+ if ((strcasecmp (words[3], "enable")) == 0 && wordcount == 4) {
type = GF_QUOTA_OPTION_TYPE_ENABLE;
goto set_type;
}
- if (strcasecmp (words[3], "disable") == 0) {
+ if (strcasecmp (words[3], "disable") == 0 && wordcount == 4) {
type = GF_QUOTA_OPTION_TYPE_DISABLE;
goto set_type;
}
@@ -447,17 +447,21 @@ cli_cmd_quota_parse (const char **words, int wordcount, dict_t **options)
return -2;
}
ret = dict_set_str (dict, "path", (char *) words[4]);
-
if (ret)
goto out;
if (!words[5]) {
- gf_log ("cli", GF_LOG_ERROR, "Please enter the limit value "
- "to be set");
+ cli_out ("Please enter the limit value to be set");
return -2;
}
+ ret = gf_string2bytesize (words[5], &value);
+ if (ret != 0) {
+ cli_out ("Please enter a correct value");
+ return -1;
+ }
+
ret = dict_set_str (dict, "limit", (char *) words[5]);
if (ret)
goto out;
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index f008384ae..3f639300f 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -1171,7 +1171,7 @@ struct cli_cmd volume_cmds[] = {
cli_cmd_volume_profile_cbk,
"volume profile operations"},
- { "volume quota <VOLNAME> <enable|disable|limit-usage|list|remove> [args] [path]",
+ { "volume quota <VOLNAME> <enable|disable|limit-usage|list|remove> [path] [value]",
cli_cmd_quota_cbk,
"quota translator specific operations"},