summaryrefslogtreecommitdiffstats
path: root/cli/src/cli-cmd-parser.c
diff options
context:
space:
mode:
authorRajesh Amaravathi <rajesh@redhat.com>2011-12-07 20:51:03 +0530
committerVijay Bellur <vijay@gluster.com>2012-01-12 01:58:26 -0800
commit169c73f28dae61236de54889edcaa8236d91da59 (patch)
treea4d74fc14c9198cbc78633a844480ab6c4ffdda3 /cli/src/cli-cmd-parser.c
parent4e40a7e48757feedc959c7982acf05c73f739a15 (diff)
cli: volume status enhancement
* Support "gluster volume status (all)" option to display all volumes' status. * On option "detail" appended to "gluster volume status *", amount of storage free, total storage, and backend filesystem details like inode size, inode count, free inodes, fs type, device name of each brick is displayed. * One can also obtain [detailed]status of only one brick. * Format of the enhanced volume status command is: "gluster volume status [all|<vol>] [<brick>] [detail]" * Some generic functions have been added to common-utils: skipword get_nth_word These functions enable parsing and fetching of words in a sentence. glusterd_get_brick_root (in glusterd) These are self explanatory. Change-Id: I6f40c1e19810f8504cd3b1786207364053d82e28 BUG: 765464 Signed-off-by: Rajesh Amaravathi <rajesh@redhat.com> Reviewed-on: http://review.gluster.com/777 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Amar Tumballi <amar@gluster.com>
Diffstat (limited to 'cli/src/cli-cmd-parser.c')
-rw-r--r--cli/src/cli-cmd-parser.c71
1 files changed, 66 insertions, 5 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index fa46fa0..acbd960 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -1795,23 +1795,84 @@ out:
return ret;
}
-int32_t
+int
cli_cmd_volume_status_parse (const char **words, int wordcount,
- dict_t **options)
+ dict_t **options)
{
dict_t *dict = NULL;
int ret = -1;
+ int cmd = 0;
- GF_ASSERT (words);
GF_ASSERT (options);
dict = dict_new ();
if (!dict)
goto out;
- GF_ASSERT(words[2]);
+ switch (wordcount) {
+
+ case 2:
+ cmd = GF_CLI_STATUS_ALL;
+ ret = 0;
+ break;
+
+ case 3:
+ if (!strcmp (words[2], "all")) {
+
+ cmd = GF_CLI_STATUS_ALL;
+ ret = 0;
+
+ } else if (!strcmp (words[2], "detail")) {
+
+ cmd = GF_CLI_STATUS_ALL_DETAIL;
+ ret = 0;
+
+ } else {
+ cmd = GF_CLI_STATUS_VOL;
+ ret = dict_set_str (dict, "volname", (char *)words[2]);
+ }
+ break;
+
+ case 4:
+ if (!strcmp (words[2], "all") &&
+ !strcmp (words[3], "detail")) {
+
+ cmd = GF_CLI_STATUS_ALL_DETAIL;
+ ret = 0;
+
+ } else if (!strcmp (words[3], "detail")) {
+ cmd = GF_CLI_STATUS_VOL_DETAIL;
+ ret = dict_set_str (dict, "volname", (char *)words[2]);
+
+ } else {
+
+ cmd = GF_CLI_STATUS_BRICK;
+ ret = dict_set_str (dict, "volname", (char *)words[2]);
+ if (ret)
+ goto out;
+ ret = dict_set_str (dict, "brick", (char *)words[3]);
+ }
+ break;
+
+ case 5:
+ if (strcmp (words[4], "detail"))
+ goto out;
+
+ cmd = GF_CLI_STATUS_BRICK_DETAIL;
+ ret = dict_set_str (dict, "volname", (char *)words[2]);
+ if (ret)
+ goto out;
+ ret = dict_set_str (dict, "brick", (char *)words[3]);
+ break;
+
+ default:
+ goto out;
+ }
+
+ if (ret)
+ goto out;
- ret = dict_set_str (dict, "volname", (char *)words[2]);
+ ret = dict_set_int32 (dict, "cmd", cmd);
if (ret)
goto out;