diff options
author | Samikshan Bairagya <samikshan@gmail.com> | 2017-07-23 22:07:34 +0530 |
---|---|---|
committer | Atin Mukherjee <amukherj@redhat.com> | 2017-07-25 05:04:47 +0000 |
commit | 8dcf91660e0bd10eb75ef25a29ca02ec51c81be4 (patch) | |
tree | 9d04445166ec8e51472cf8ee7aa73f285266ac01 /xlators | |
parent | 669868d23eaeba42809fca7be134137c607d64ed (diff) |
glusterd: Add option to get all volume options through get-state CLI
This commit makes the get-state CLI capable to returning the values
for all volume options for all volumes. This is similar to what you
get when you issue a `gluster volume get <volname> all` command.
This is the new usage for the get-state CLI:
# gluster get-state [<daemon>] [[odir </path/to/output/dir/>] \
[file <filename>]] [detail|volumeoptions]
Fixes: #277
Change-Id: Ice52d936a5a389c6fa0ba5ab32416a65cdfde46d
Signed-off-by: Samikshan Bairagya <samikshan@gmail.com>
Reviewed-on: https://review.gluster.org/17858
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Reviewed-by: Gaurav Yadav <gyadav@redhat.com>
Smoke: Gluster Build System <jenkins@build.gluster.org>
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-handler.c | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index 2968c1413d6..126d5f211d0 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -5219,6 +5219,7 @@ glusterd_get_state (rpcsvc_request_t *req, dict_t *dict) glusterd_volinfo_t *volinfo = NULL; glusterd_brickinfo_t *brickinfo = NULL; xlator_t *this = NULL; + dict_t *vol_all_opts = NULL; struct statvfs brickstat = {0}; char *odir = NULL; char *filename = NULL; @@ -5312,6 +5313,41 @@ glusterd_get_state (rpcsvc_request_t *req, dict_t *dict) goto out; } + ret = dict_get_uint32 (dict, "getstate-cmd", &get_state_cmd); + if (ret) { + gf_msg_debug (this->name, 0, "get-state command type not set"); + ret = 0; + } + + if (get_state_cmd == GF_CLI_GET_STATE_VOLOPTS) { + fprintf (fp, "[Volume Options]\n"); + cds_list_for_each_entry (volinfo, &priv->volumes, vol_list) { + fprintf (fp, "Volume%d.name: %s\n", + ++count, volinfo->volname); + + volcount = count; + vol_all_opts = dict_new (); + + ret = glusterd_get_default_val_for_volopt (vol_all_opts, + _gf_true, NULL, NULL, volinfo, &rsp.op_errstr); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_VOL_OPTS_IMPORT_FAIL, "Failed to " + "fetch the value of all volume options " + "for volume %s", volinfo->volname); + continue; + } + + dict_foreach (vol_all_opts, glusterd_print_volume_options, + fp); + + if (vol_all_opts) + dict_unref (vol_all_opts); + } + ret = 0; + goto out; + } + fprintf (fp, "[Global]\n"); fprintf (fp, "MYUUID: %s\n", gf_strdup (uuid_utoa (priv->uuid))); @@ -5353,12 +5389,6 @@ glusterd_get_state (rpcsvc_request_t *req, dict_t *dict) } rcu_read_unlock (); - ret = dict_get_uint32 (dict, "getstate-cmd", &get_state_cmd); - if (ret) { - gf_msg_debug (this->name, 0, "get-state command type not set"); - ret = 0; - } - count = 0; fprintf (fp, "\n[Volumes]\n"); @@ -5633,7 +5663,8 @@ out: fclose(fp); rsp.op_ret = ret; - rsp.op_errstr = err_str; + if (rsp.op_errstr == NULL) + rsp.op_errstr = err_str; ret = dict_allocate_and_serialize (dict, &rsp.dict.dict_val, &rsp.dict.dict_len); |