diff options
author | Amar Tumballi <amar@gluster.com> | 2010-08-31 07:51:14 +0000 |
---|---|---|
committer | Vijay Bellur <vijay@dev.gluster.com> | 2010-08-31 10:49:40 -0700 |
commit | 6530488a49ed0c9395b091c42b148091075a9d86 (patch) | |
tree | 18c85cb3bfa4fc0f0dce0aef27bf6af1ade19af9 /cli/src/cli-cmd-parser.c | |
parent | da5bf7cf104cd060b2f94d47132029689bfff685 (diff) |
'gluster volume log' feature added
* 'gluster volume log filename <VOLNAME> [BRICK] <path>'
* 'gluster volume log locate <VOLNAME> [BRICK]'
* 'gluster volume log rotate <VOLUME> [BRICK]'
Signed-off-by: Amar Tumballi <amar@gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>
Diffstat (limited to 'cli/src/cli-cmd-parser.c')
-rw-r--r-- | cli/src/cli-cmd-parser.c | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 79f56e2d4b6..48c4a4fd9ef 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -642,3 +642,138 @@ out: return ret; } + +int32_t +cli_cmd_log_filename_parse (const char **words, int wordcount, dict_t **options) +{ + dict_t *dict = NULL; + char *volname = NULL; + char *str = NULL; + int ret = -1; + + GF_ASSERT (words); + GF_ASSERT (options); + + GF_ASSERT ((strcmp (words[0], "volume")) == 0); + GF_ASSERT ((strcmp (words[1], "log")) == 0); + GF_ASSERT ((strcmp (words[2], "filename")) == 0); + + dict = dict_new (); + if (!dict) + goto out; + + volname = (char *)words[3]; + GF_ASSERT (volname); + + ret = dict_set_str (dict, "volname", volname); + if (ret) + goto out; + + str = (char *)words[4]; + if (strchr (str, ':')) { + ret = dict_set_str (dict, "brick", str); + if (ret) + goto out; + /* Path */ + str = (char *)words[5]; + ret = dict_set_str (dict, "path", str); + if (ret) + goto out; + } else { + ret = dict_set_str (dict, "path", str); + if (ret) + goto out; + } + + *options = dict; + +out: + if (ret && dict) + dict_destroy (dict); + + return ret; +} + +int32_t +cli_cmd_log_locate_parse (const char **words, int wordcount, dict_t **options) +{ + dict_t *dict = NULL; + char *volname = NULL; + char *str = NULL; + int ret = -1; + + GF_ASSERT (words); + GF_ASSERT (options); + + GF_ASSERT ((strcmp (words[0], "volume")) == 0); + GF_ASSERT ((strcmp (words[1], "log")) == 0); + GF_ASSERT ((strcmp (words[2], "locate")) == 0); + + dict = dict_new (); + if (!dict) + goto out; + + volname = (char *)words[3]; + GF_ASSERT (volname); + + ret = dict_set_str (dict, "volname", volname); + if (ret) + goto out; + + str = (char *)words[4]; + if (str && strchr (str, ':')) { + ret = dict_set_str (dict, "brick", str); + if (ret) + goto out; + } + + *options = dict; + +out: + if (ret && dict) + dict_destroy (dict); + + return ret; +} + +int32_t +cli_cmd_log_rotate_parse (const char **words, int wordcount, dict_t **options) +{ + dict_t *dict = NULL; + char *volname = NULL; + char *str = NULL; + int ret = -1; + + GF_ASSERT (words); + GF_ASSERT (options); + + GF_ASSERT ((strcmp (words[0], "volume")) == 0); + GF_ASSERT ((strcmp (words[1], "log")) == 0); + GF_ASSERT ((strcmp (words[2], "rotate")) == 0); + + dict = dict_new (); + if (!dict) + goto out; + + volname = (char *)words[3]; + GF_ASSERT (volname); + + ret = dict_set_str (dict, "volname", volname); + if (ret) + goto out; + + str = (char *)words[4]; + if (str && strchr (str, ':')) { + ret = dict_set_str (dict, "brick", str); + if (ret) + goto out; + } + + *options = dict; + +out: + if (ret && dict) + dict_destroy (dict); + + return ret; +} |