|
|
21ab4e |
From 8816a046c4c249b99ca5dff1aaaac031c7c4dae4 Mon Sep 17 00:00:00 2001
|
|
|
21ab4e |
From: Samikshan Bairagya <samikshan@gmail.com>
|
|
|
21ab4e |
Date: Sun, 23 Jul 2017 22:07:34 +0530
|
|
|
21ab4e |
Subject: [PATCH 614/616] glusterd: Add option to get all volume options
|
|
|
21ab4e |
through get-state CLI
|
|
|
21ab4e |
|
|
|
21ab4e |
This commit makes the get-state CLI capable to returning the values
|
|
|
21ab4e |
for all volume options for all volumes. This is similar to what you
|
|
|
21ab4e |
get when you issue a `gluster volume get <volname> all` command.
|
|
|
21ab4e |
|
|
|
21ab4e |
This is the new usage for the get-state CLI:
|
|
|
21ab4e |
|
|
|
21ab4e |
# gluster get-state [<daemon>] [[odir </path/to/output/dir/>] \
|
|
|
21ab4e |
[file <filename>]] [detail|volumeoptions]
|
|
|
21ab4e |
|
|
|
21ab4e |
>Fixes: #277
|
|
|
21ab4e |
>Change-Id: Ice52d936a5a389c6fa0ba5ab32416a65cdfde46d
|
|
|
21ab4e |
>Signed-off-by: Samikshan Bairagya <samikshan@gmail.com>
|
|
|
21ab4e |
>Reviewed-on: https://review.gluster.org/17858
|
|
|
21ab4e |
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
>Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
21ab4e |
>Reviewed-by: Gaurav Yadav <gyadav@redhat.com>
|
|
|
21ab4e |
>Smoke: Gluster Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
|
|
|
21ab4e |
Bug: 1475326
|
|
|
21ab4e |
>Change-Id: Ice52d936a5a389c6fa0ba5ab32416a65cdfde46d
|
|
|
21ab4e |
>Signed-off-by: Samikshan Bairagya <samikshan@gmail.com>
|
|
|
21ab4e |
|
|
|
21ab4e |
Change-Id: Ifd2d6f56576d631c0fef50e89b0b8885dedd5131
|
|
|
21ab4e |
Reviewed-on: https://code.engineering.redhat.com/gerrit/117182
|
|
|
21ab4e |
Tested-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
21ab4e |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
21ab4e |
---
|
|
|
21ab4e |
cli/src/cli-cmd-global.c | 4 +-
|
|
|
21ab4e |
cli/src/cli-cmd-parser.c | 28 ++++++++++----
|
|
|
21ab4e |
doc/gluster.8 | 2 +-
|
|
|
21ab4e |
rpc/xdr/src/cli1-xdr.x | 3 +-
|
|
|
21ab4e |
.../cli/bug-1353156-get-state-cli-validations.t | 18 +++++++++
|
|
|
21ab4e |
xlators/mgmt/glusterd/src/glusterd-handler.c | 45 ++++++++++++++++++----
|
|
|
21ab4e |
6 files changed, 81 insertions(+), 19 deletions(-)
|
|
|
21ab4e |
|
|
|
21ab4e |
diff --git a/cli/src/cli-cmd-global.c b/cli/src/cli-cmd-global.c
|
|
|
21ab4e |
index 4312d24..d79f3a8 100644
|
|
|
21ab4e |
--- a/cli/src/cli-cmd-global.c
|
|
|
21ab4e |
+++ b/cli/src/cli-cmd-global.c
|
|
|
21ab4e |
@@ -47,8 +47,8 @@ struct cli_cmd global_cmds[] = {
|
|
|
21ab4e |
cli_cmd_ganesha_cbk,
|
|
|
21ab4e |
"Enable/disable NFS-Ganesha support",
|
|
|
21ab4e |
},
|
|
|
21ab4e |
- { "get-state [<daemon>] [odir </path/to/output/dir/>] "
|
|
|
21ab4e |
- "[file <filename>]] [detail]",
|
|
|
21ab4e |
+ { "get-state [<daemon>] [[odir </path/to/output/dir/>] "
|
|
|
21ab4e |
+ "[file <filename>]] [detail|volumeoptions]",
|
|
|
21ab4e |
cli_cmd_get_state_cbk,
|
|
|
21ab4e |
"Get local state representation of mentioned daemon",
|
|
|
21ab4e |
},
|
|
|
21ab4e |
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
|
|
|
21ab4e |
index a068beb..71af744 100644
|
|
|
21ab4e |
--- a/cli/src/cli-cmd-parser.c
|
|
|
21ab4e |
+++ b/cli/src/cli-cmd-parser.c
|
|
|
21ab4e |
@@ -990,10 +990,16 @@ cli_cmd_get_state_parse (struct cli_state *state,
|
|
|
21ab4e |
}
|
|
|
21ab4e |
} else {
|
|
|
21ab4e |
if (count > 1) {
|
|
|
21ab4e |
- if (count == wordcount-1 &&
|
|
|
21ab4e |
- !strcmp (words[count], "detail")) {
|
|
|
21ab4e |
- cmd = GF_CLI_GET_STATE_DETAIL;
|
|
|
21ab4e |
- continue;
|
|
|
21ab4e |
+ if (count == wordcount-1) {
|
|
|
21ab4e |
+ if (strcmp (words[count],
|
|
|
21ab4e |
+ "detail") == 0) {
|
|
|
21ab4e |
+ cmd = GF_CLI_GET_STATE_DETAIL;
|
|
|
21ab4e |
+ continue;
|
|
|
21ab4e |
+ } else if (strcmp (words[count],
|
|
|
21ab4e |
+ "volumeoptions") == 0) {
|
|
|
21ab4e |
+ cmd = GF_CLI_GET_STATE_VOLOPTS;
|
|
|
21ab4e |
+ continue;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
} else {
|
|
|
21ab4e |
*op_errstr = gf_strdup ("Problem"
|
|
|
21ab4e |
" parsing arguments. "
|
|
|
21ab4e |
@@ -1006,10 +1012,16 @@ cli_cmd_get_state_parse (struct cli_state *state,
|
|
|
21ab4e |
if (strcmp (words[count], "glusterd") == 0) {
|
|
|
21ab4e |
continue;
|
|
|
21ab4e |
} else {
|
|
|
21ab4e |
- if (count == wordcount-1 &&
|
|
|
21ab4e |
- !strcmp (words[count], "detail")) {
|
|
|
21ab4e |
- cmd = GF_CLI_GET_STATE_DETAIL;
|
|
|
21ab4e |
- continue;
|
|
|
21ab4e |
+ if (count == wordcount-1) {
|
|
|
21ab4e |
+ if (strcmp (words[count],
|
|
|
21ab4e |
+ "detail") == 0) {
|
|
|
21ab4e |
+ cmd = GF_CLI_GET_STATE_DETAIL;
|
|
|
21ab4e |
+ continue;
|
|
|
21ab4e |
+ } else if (strcmp (words[count],
|
|
|
21ab4e |
+ "volumeoptions") == 0) {
|
|
|
21ab4e |
+ cmd = GF_CLI_GET_STATE_VOLOPTS;
|
|
|
21ab4e |
+ continue;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
*op_errstr = gf_strdup ("glusterd is "
|
|
|
21ab4e |
diff --git a/doc/gluster.8 b/doc/gluster.8
|
|
|
21ab4e |
index c7b6f22..ed6f644 100644
|
|
|
21ab4e |
--- a/doc/gluster.8
|
|
|
21ab4e |
+++ b/doc/gluster.8
|
|
|
21ab4e |
@@ -269,7 +269,7 @@ Selects <HOSTNAME:BRICKNAME> as the source for all the files that are in split-b
|
|
|
21ab4e |
Selects the split-brained <FILE> present in <HOSTNAME:BRICKNAME> as source and completes heal.
|
|
|
21ab4e |
.SS "Other Commands"
|
|
|
21ab4e |
.TP
|
|
|
21ab4e |
-\fB\ get-state [<daemon>] [[odir </path/to/output/dir/>] [file <filename>]] [detail] \fR
|
|
|
21ab4e |
+\fB\ get-state [<daemon>] [[odir </path/to/output/dir/>] [file <filename>]] [detail|volumeoptions] \fR
|
|
|
21ab4e |
Get local state representation of mentioned daemon and store data in provided path information
|
|
|
21ab4e |
.TP
|
|
|
21ab4e |
\fB\ help \fR
|
|
|
21ab4e |
diff --git a/rpc/xdr/src/cli1-xdr.x b/rpc/xdr/src/cli1-xdr.x
|
|
|
21ab4e |
index c90d564..e33ea4f 100644
|
|
|
21ab4e |
--- a/rpc/xdr/src/cli1-xdr.x
|
|
|
21ab4e |
+++ b/rpc/xdr/src/cli1-xdr.x
|
|
|
21ab4e |
@@ -132,7 +132,8 @@ enum gf1_cli_info_op {
|
|
|
21ab4e |
};
|
|
|
21ab4e |
|
|
|
21ab4e |
enum gf_cli_get_state_op {
|
|
|
21ab4e |
- GF_CLI_GET_STATE_DETAIL = 1
|
|
|
21ab4e |
+ GF_CLI_GET_STATE_DETAIL = 1,
|
|
|
21ab4e |
+ GF_CLI_GET_STATE_VOLOPTS = 2
|
|
|
21ab4e |
};
|
|
|
21ab4e |
|
|
|
21ab4e |
enum gf1_cli_top_op {
|
|
|
21ab4e |
diff --git a/tests/bugs/cli/bug-1353156-get-state-cli-validations.t b/tests/bugs/cli/bug-1353156-get-state-cli-validations.t
|
|
|
21ab4e |
index f6e72a5..c9c06cc 100644
|
|
|
21ab4e |
--- a/tests/bugs/cli/bug-1353156-get-state-cli-validations.t
|
|
|
21ab4e |
+++ b/tests/bugs/cli/bug-1353156-get-state-cli-validations.t
|
|
|
21ab4e |
@@ -87,6 +87,16 @@ TEST positive_test $CLI get-state glusterd odir $ODIR detail
|
|
|
21ab4e |
|
|
|
21ab4e |
TEST positive_test $CLI get-state glusterd odir $ODIR file gdstate detail
|
|
|
21ab4e |
|
|
|
21ab4e |
+TEST positive_test $CLI get-state volumeoptions
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+TEST positive_test $CLI get-state glusterd volumeoptions
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+TEST positive_test $CLI get-state odir $ODIR volumeoptions
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+TEST positive_test $CLI get-state glusterd odir $ODIR volumeoptions
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+TEST positive_test $CLI get-state glusterd odir $ODIR file gdstate volumeoptions
|
|
|
21ab4e |
+
|
|
|
21ab4e |
TEST ! $CLI get-state glusterfsd odir $ODIR;
|
|
|
21ab4e |
ERRSTR=$($CLI get-state glusterfsd odir $ODIR 2>&1 >/dev/null);
|
|
|
21ab4e |
EXPECT 'glusterd' get_daemon_not_supported_part $ERRSTR;
|
|
|
21ab4e |
@@ -127,4 +137,12 @@ TEST ! $CLI get-state glusterd foo bar detail;
|
|
|
21ab4e |
ERRSTR=$($CLI get-state glusterd foo bar 2>&1 >/dev/null);
|
|
|
21ab4e |
EXPECT 'Problem' get_parsing_arguments_part $ERRSTR;
|
|
|
21ab4e |
|
|
|
21ab4e |
+TEST ! $CLI get-state glusterd volumeoptions file gdstate;
|
|
|
21ab4e |
+ERRSTR=$($CLI get-state glusterd foo bar 2>&1 >/dev/null);
|
|
|
21ab4e |
+EXPECT 'Problem' get_parsing_arguments_part $ERRSTR;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+TEST ! $CLI get-state glusterd foo bar volumeoptions;
|
|
|
21ab4e |
+ERRSTR=$($CLI get-state glusterd foo bar 2>&1 >/dev/null);
|
|
|
21ab4e |
+EXPECT 'Problem' get_parsing_arguments_part $ERRSTR;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
cleanup;
|
|
|
21ab4e |
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
|
|
|
21ab4e |
index 7e24c9b..e194dca 100644
|
|
|
21ab4e |
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
|
|
|
21ab4e |
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
|
|
|
21ab4e |
@@ -5270,6 +5270,7 @@ glusterd_get_state (rpcsvc_request_t *req, dict_t *dict)
|
|
|
21ab4e |
glusterd_brickinfo_t *brickinfo = NULL;
|
|
|
21ab4e |
glusterd_snap_t *snapinfo = NULL;
|
|
|
21ab4e |
xlator_t *this = NULL;
|
|
|
21ab4e |
+ dict_t *vol_all_opts = NULL;
|
|
|
21ab4e |
struct statvfs brickstat = {0};
|
|
|
21ab4e |
char *odir = NULL;
|
|
|
21ab4e |
char *filename = NULL;
|
|
|
21ab4e |
@@ -5364,6 +5365,41 @@ glusterd_get_state (rpcsvc_request_t *req, dict_t *dict)
|
|
|
21ab4e |
goto out;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
+ ret = dict_get_uint32 (dict, "getstate-cmd", &get_state_cmd);
|
|
|
21ab4e |
+ if (ret) {
|
|
|
21ab4e |
+ gf_msg_debug (this->name, 0, "get-state command type not set");
|
|
|
21ab4e |
+ ret = 0;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ if (get_state_cmd == GF_CLI_GET_STATE_VOLOPTS) {
|
|
|
21ab4e |
+ fprintf (fp, "[Volume Options]\n");
|
|
|
21ab4e |
+ cds_list_for_each_entry (volinfo, &priv->volumes, vol_list) {
|
|
|
21ab4e |
+ fprintf (fp, "Volume%d.name: %s\n",
|
|
|
21ab4e |
+ ++count, volinfo->volname);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ volcount = count;
|
|
|
21ab4e |
+ vol_all_opts = dict_new ();
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ ret = glusterd_get_default_val_for_volopt (vol_all_opts,
|
|
|
21ab4e |
+ _gf_true, NULL, NULL, volinfo, &rsp.op_errstr);
|
|
|
21ab4e |
+ if (ret) {
|
|
|
21ab4e |
+ gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
21ab4e |
+ GD_MSG_VOL_OPTS_IMPORT_FAIL, "Failed to "
|
|
|
21ab4e |
+ "fetch the value of all volume options "
|
|
|
21ab4e |
+ "for volume %s", volinfo->volname);
|
|
|
21ab4e |
+ continue;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ dict_foreach (vol_all_opts, glusterd_print_volume_options,
|
|
|
21ab4e |
+ fp);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ if (vol_all_opts)
|
|
|
21ab4e |
+ dict_unref (vol_all_opts);
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+ ret = 0;
|
|
|
21ab4e |
+ goto out;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
fprintf (fp, "[Global]\n");
|
|
|
21ab4e |
|
|
|
21ab4e |
fprintf (fp, "MYUUID: %s\n", gf_strdup (uuid_utoa (priv->uuid)));
|
|
|
21ab4e |
@@ -5405,12 +5441,6 @@ glusterd_get_state (rpcsvc_request_t *req, dict_t *dict)
|
|
|
21ab4e |
}
|
|
|
21ab4e |
rcu_read_unlock ();
|
|
|
21ab4e |
|
|
|
21ab4e |
- ret = dict_get_uint32 (dict, "getstate-cmd", &get_state_cmd);
|
|
|
21ab4e |
- if (ret) {
|
|
|
21ab4e |
- gf_msg_debug (this->name, 0, "get-state command type not set");
|
|
|
21ab4e |
- ret = 0;
|
|
|
21ab4e |
- }
|
|
|
21ab4e |
-
|
|
|
21ab4e |
count = 0;
|
|
|
21ab4e |
fprintf (fp, "\n[Volumes]\n");
|
|
|
21ab4e |
|
|
|
21ab4e |
@@ -5708,7 +5738,8 @@ out:
|
|
|
21ab4e |
fclose(fp);
|
|
|
21ab4e |
|
|
|
21ab4e |
rsp.op_ret = ret;
|
|
|
21ab4e |
- rsp.op_errstr = err_str;
|
|
|
21ab4e |
+ if (rsp.op_errstr == NULL)
|
|
|
21ab4e |
+ rsp.op_errstr = err_str;
|
|
|
21ab4e |
|
|
|
21ab4e |
ret = dict_allocate_and_serialize (dict, &rsp.dict.dict_val,
|
|
|
21ab4e |
&rsp.dict.dict_len);
|
|
|
21ab4e |
--
|
|
|
21ab4e |
1.8.3.1
|
|
|
21ab4e |
|