diff options
Diffstat (limited to 'cli/src/cli-cmd-parser.c')
-rw-r--r-- | cli/src/cli-cmd-parser.c | 59 |
1 files changed, 19 insertions, 40 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 98ed0fdd..18bc53f8 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -532,10 +532,9 @@ cli_cmd_quota_parse (const char **words, int wordcount, dict_t **options) uint64_t value = 0; gf_quota_type type = GF_QUOTA_OPTION_TYPE_NONE; char *opwords[] = { "enable", "disable", "limit-usage", - "remove", "list", "soft-limit", - "alert-time", "soft-timeout", - "hard-timeout", "default-soft-limit", - NULL}; + "remove", "list", "alert-time", + "soft-timeout", "hard-timeout", + "default-soft-limit", NULL}; char *w = NULL; uint32_t time = 0; double percent = 0; @@ -610,7 +609,7 @@ cli_cmd_quota_parse (const char **words, int wordcount, dict_t **options) } if (strcmp (w, "limit-usage") == 0) { - if (wordcount != 6) { + if (wordcount < 6 || wordcount > 7) { ret = -1; goto out; } @@ -638,10 +637,24 @@ cli_cmd_quota_parse (const char **words, int wordcount, dict_t **options) goto out; } - ret = dict_set_str (dict, "limit", (char *) words[5]); + ret = dict_set_str (dict, "hard-limit", (char *) words[5]); if (ret < 0) goto out; + if (wordcount == 7) { + + ret = gf_string2percent (words[6], &percent); + if (ret != 0) { + cli_err ("Please enter a correct value"); + goto out; + } + + ret = dict_set_str (dict, "soft-limit", + (char *) words[6]); + if (ret < 0) + goto out; + } + goto set_type; } if (strcmp (w, "remove") == 0) { @@ -688,41 +701,7 @@ cli_cmd_quota_parse (const char **words, int wordcount, dict_t **options) goto set_type; } - if (strcmp (w, "soft-limit") == 0) { - if (wordcount != 6) { - ret = -1; - goto out; - } - type = GF_QUOTA_OPTION_TYPE_SOFT_LIMIT; - if (words[4][0] != '/') { - cli_err ("Please enter absolute path"); - ret = -1; - goto out; - } - ret = dict_set_str (dict, "path", (char *) words[4]); - if (ret) - goto out; - - if (!words[5]) { - cli_err ("Please enter the limit value to be set"); - ret = -1; - goto out; - } - - ret = gf_string2percent (words[5], &percent); - if (ret != 0) { - cli_err ("Please enter a correct value"); - goto out; - } - - ret = dict_set_str (dict, "limit", (char *) words[5]); - if (ret < 0) - goto out; - - goto set_type; - - } if (strcmp (w, "alert-time") == 0) { if (wordcount != 5) { ret = -1; |