diff options
Diffstat (limited to 'cli/src/cli-cmd-parser.c')
-rw-r--r-- | cli/src/cli-cmd-parser.c | 132 |
1 files changed, 121 insertions, 11 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 484c4a34..78f680da 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -532,8 +532,13 @@ 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", "version", NULL }; + "remove", "list", "soft-limit", + "alert-time", "soft-timeout", + "hard-timeout", "default-soft-limit", + NULL}; char *w = NULL; + uint32_t time = 0; + double percent = 0; GF_ASSERT (words); GF_ASSERT (options); @@ -614,8 +619,8 @@ cli_cmd_quota_parse (const char **words, int wordcount, dict_t **options) if (words[4][0] != '/') { cli_err ("Please enter absolute path"); - - return -2; + ret = -1; + goto out; } ret = dict_set_str (dict, "path", (char *) words[4]); if (ret) @@ -623,14 +628,14 @@ cli_cmd_quota_parse (const char **words, int wordcount, dict_t **options) if (!words[5]) { cli_err ("Please enter the limit value to be set"); - - return -2; + ret = -1; + goto out; } ret = gf_string2bytesize (words[5], &value); if (ret != 0) { cli_err ("Please enter a correct value"); - return -1; + goto out; } ret = dict_set_str (dict, "limit", (char *) words[5]); @@ -649,8 +654,8 @@ cli_cmd_quota_parse (const char **words, int wordcount, dict_t **options) if (words[4][0] != '/') { cli_err ("Please enter absolute path"); - - return -2; + ret = -1; + goto out; } ret = dict_set_str (dict, "path", (char *) words[4]); @@ -683,8 +688,109 @@ cli_cmd_quota_parse (const char **words, int wordcount, dict_t **options) goto set_type; } - if (strcmp (w, "version") == 0) { - type = GF_QUOTA_OPTION_TYPE_VERSION; + 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; + goto out; + } + type = GF_QUOTA_OPTION_TYPE_ALERT_TIME; + + ret = gf_string2time (words[4], &time); + if (ret) { + cli_err ("Invalid argument %s. Please enter a valid " + "string", words[4]); + goto out; + } + + ret = dict_set_str (dict, "value", (char *)words[4]); + if (ret < 0) + goto out; + goto set_type; + } + if (strcmp (w, "soft-timeout") == 0) { + if (wordcount != 5) { + ret = -1; + goto out; + } + type = GF_QUOTA_OPTION_TYPE_SOFT_TIMEOUT; + + ret = gf_string2time (words[4], &time); + if (ret) { + cli_err ("Invalid argument %s. Please enter a valid " + "string", words[4]); + goto out; + } + + ret = dict_set_str (dict, "value", (char *)words[4]); + if (ret < 0) + goto out; + goto set_type; + } + if (strcmp (w, "hard-timeout") == 0) { + if(wordcount != 5) { + ret = -1; + goto out; + } + type = GF_QUOTA_OPTION_TYPE_HARD_TIMEOUT; + + ret = gf_string2time (words[4], &time); + if (ret) { + cli_err ("Invalid argument %s. Please enter a valid " + "string", words[4]); + goto out; + } + + ret = dict_set_str (dict, "value", (char *)words[4]); + if (ret < 0) + goto out; + goto set_type; + } + if (strcmp (w, "default-soft-limit") == 0) { + if(wordcount != 5) { + ret = -1; + goto out; + } + type = GF_QUOTA_OPTION_TYPE_DEFAULT_SOFT_LIMIT; + + ret = dict_set_str (dict, "value", (char *)words[4]); + if (ret < 0) + goto out; + goto set_type; } else { GF_ASSERT (!"opword mismatch"); } @@ -2241,7 +2347,7 @@ cli_cmd_validate_dumpoption (const char *arg, char **option) { char *opwords[] = {"all", "nfs", "mem", "iobuf", "callpool", "priv", "fd", "inode", "history", "inodectx", "fdctx", - NULL}; + "quotad", NULL}; char *w = NULL; w = str_getunamb (arg, opwords); @@ -2273,6 +2379,10 @@ cli_cmd_volume_statedump_options_parse (const char **words, int wordcount, strncat (option_str, option, strlen (option)); strncat (option_str, " ", 1); } + if((strstr (option_str, "nfs")) && strstr (option_str, "quotad")) { + ret = -1; + goto out; + } dict = dict_new (); if (!dict) |