summaryrefslogtreecommitdiffstats
path: root/cli/src/cli-cmd-parser.c
diff options
context:
space:
mode:
authorSamikshan Bairagya <samikshan@gmail.com>2017-04-05 18:03:10 +0530
committerAtin Mukherjee <amukherj@redhat.com>2017-04-12 23:43:08 -0400
commitb4beaa0505e8b23ac027fb6c995aa259c3f7550a (patch)
treece6702fd243088b829d87599a98839c8491a1c62 /cli/src/cli-cmd-parser.c
parente536bea09aa0776164716f9a0d480584c0a761f2 (diff)
glusterd: Add client details to get-state output
This commit optionally adds client details corresponding to the locally running bricks to the get-state output. Since getting the client details involves sending RPC requests to the respective local bricks, this is a relatively more costly operation. These client details would be added to the get-state output only if the get-state command is invoked with the 'detail' option. This commit therefore also changes the get-state CLI usage. The modified usage is as follows: # gluster get-state [<daemon>] [[odir </path/to/output/dir/>] \ [file <filename>]] [detail] Change-Id: I42cd4ef160f9e96d55a08a10d32c8ba44e4cd3d8 BUG: 1431183 Signed-off-by: Samikshan Bairagya <samikshan@gmail.com> Reviewed-on: https://review.gluster.org/17003 NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Smoke: Gluster Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Diffstat (limited to 'cli/src/cli-cmd-parser.c')
-rw-r--r--cli/src/cli-cmd-parser.c36
1 files changed, 31 insertions, 5 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index be53cd2ed40..c43b52b63a2 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -829,6 +829,7 @@ cli_cmd_get_state_parse (struct cli_state *state,
char *filename = NULL;
char *daemon_name = NULL;
int count = 0;
+ uint32_t cmd = 0;
GF_VALIDATE_OR_GOTO ("cli", options, out);
GF_VALIDATE_OR_GOTO ("cli", words, out);
@@ -837,7 +838,7 @@ cli_cmd_get_state_parse (struct cli_state *state,
if (!dict)
goto out;
- if (wordcount < 1 || wordcount > 6) {
+ if (wordcount < 1 || wordcount > 7) {
*op_errstr = gf_strdup ("Problem parsing arguments."
" Check usage.");
goto out;
@@ -868,16 +869,28 @@ cli_cmd_get_state_parse (struct cli_state *state,
}
} else {
if (count > 1) {
- *op_errstr = gf_strdup ("Problem "
- "parsing arguments. "
+ if (count == wordcount-1 &&
+ !strcmp (words[count], "detail")) {
+ cmd = GF_CLI_GET_STATE_DETAIL;
+ continue;
+ } else {
+ *op_errstr = gf_strdup ("Problem"
+ " parsing arguments. "
"Check usage.");
- ret = -1;
- goto out;
+ ret = -1;
+ goto out;
+ }
}
if (strcmp (words[count], "glusterd") == 0) {
continue;
} else {
+ if (count == wordcount-1 &&
+ !strcmp (words[count], "detail")) {
+ cmd = GF_CLI_GET_STATE_DETAIL;
+ continue;
+ }
+
*op_errstr = gf_strdup ("glusterd is "
"the only supported daemon.");
ret = -1;
@@ -919,6 +932,19 @@ cli_cmd_get_state_parse (struct cli_state *state,
goto out;
}
}
+
+ if (cmd) {
+ ret = dict_set_uint32 (dict, "getstate-cmd", cmd);
+ if (ret) {
+ *op_errstr = gf_strdup ("Command failed. Please"
+ " check log file for"
+ " more details.");
+ gf_log (THIS->name, GF_LOG_ERROR, "Setting "
+ "get-state command type to dictionary "
+ "failed");
+ goto out;
+ }
+ }
}
out: