diff options
author | Kaushal M <kaushal@redhat.com> | 2012-04-11 17:04:15 +0530 |
---|---|---|
committer | Vijay Bellur <vijay@gluster.com> | 2012-04-17 06:21:05 -0700 |
commit | 79620e8f63148b1ad7d8180da46176a759435590 (patch) | |
tree | 5d95855cb4cd33f24a1451e3aa7dd99c82bfe945 /cli/src | |
parent | 4359d00fcb17d22ef487bff34943475c77194692 (diff) |
cli: Fix for "volume status all"
Fixes output of "volume status all" when some volumes are stopped and some
changes to xml output.
Change-Id: I77938422c0258bb69e32b54c23df1225474532bc
BUG: 811539
Signed-off-by: Kaushal M <kaushal@redhat.com>
Reviewed-on: http://review.gluster.com/3130
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'cli/src')
-rw-r--r-- | cli/src/cli-rpc-ops.c | 57 | ||||
-rw-r--r-- | cli/src/cli.h | 2 |
2 files changed, 50 insertions, 9 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 4a1ff22b8ef..61c117162e2 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -5275,6 +5275,8 @@ gf_cli3_1_status_cbk (struct rpc_req *req, struct iovec *iov, dict_t *dict = NULL; gf_cli_rsp rsp = {0,}; cli_volume_status_t status = {0}; + cli_local_t *local = NULL; + char msg[1024] = {0,}; if (req->rpc_status == -1) goto out; @@ -5287,10 +5289,32 @@ gf_cli3_1_status_cbk (struct rpc_req *req, struct iovec *iov, gf_log ("cli", GF_LOG_DEBUG, "Received response to status cmd"); - if (rsp.op_ret && strcmp (rsp.op_errstr, "")) - cli_out ("%s", rsp.op_errstr); - else if (rsp.op_ret) - cli_out ("Unable to obtain volume status information."); + local = ((call_frame_t *)myframe)->local; + + if (rsp.op_ret) { + if (strcmp (rsp.op_errstr, "")) + snprintf (msg, sizeof (msg), "%s", rsp.op_errstr); + else + snprintf (msg, sizeof (msg), "Unable to obtain volume " + "status information."); + +#if (HAVE_LIB_XML) + if (global_state->mode & GLUSTER_MODE_XML) { + cli_xml_output_str ("volStatus", msg, rsp.op_ret, + rsp.op_errno, rsp.op_errstr); + ret = 0; + goto out; + } +#endif + cli_out ("%s", msg); + if (local && local->all) { + ret = 0; + cli_out (" "); + } else + ret = -1; + + goto out; + } dict = dict_new (); if (!dict) @@ -5307,8 +5331,13 @@ gf_cli3_1_status_cbk (struct rpc_req *req, struct iovec *iov, goto out; if ((cmd & GF_CLI_STATUS_ALL)) { - ((call_frame_t *)myframe)->local = dict; - ret = 0; + if (local) { + local->dict = dict; + ret = 0; + } else { + gf_log ("cli", GF_LOG_ERROR, "local not found"); + ret = -1; + } goto out; } @@ -5375,7 +5404,7 @@ gf_cli3_1_status_cbk (struct rpc_req *req, struct iovec *iov, if (ret) goto out; - cli_out ("\nStatus of volume: %s", volname); + cli_out ("Status of volume: %s", volname); if ((cmd & GF_CLI_STATUS_DETAIL) == 0) { cli_out ("Gluster process\t\t\t\t\t\tPort\tOnline\tPid"); @@ -5445,7 +5474,7 @@ gf_cli3_1_status_cbk (struct rpc_req *req, struct iovec *iov, cli_print_brick_status (&status); } } - + cli_out (" "); cont: ret = rsp.op_ret; @@ -5500,17 +5529,27 @@ gf_cli_status_volume_all (call_frame_t *frame, xlator_t *this, void *data) char *volname = NULL; dict_t *vol_dict = NULL; dict_t *dict = NULL; + cli_local_t *local = NULL; dict = (dict_t *)data; ret = dict_get_uint32 (dict, "cmd", &cmd); if (ret) goto out; + local = cli_local_get (); + if (!local) { + ret = -1; + gf_log ("cli", GF_LOG_ERROR, "Failed to allocate local"); + goto out; + } + frame->local = local; + local->all = _gf_true; + ret = gf_cli3_1_status_volume (frame, this, data); if (ret) goto out; - vol_dict = (dict_t *)(frame->local); + vol_dict = local->dict; ret = dict_get_int32 (vol_dict, "vol_count", &vol_count); if (ret) { diff --git a/cli/src/cli.h b/cli/src/cli.h index 2a24378ffa1..f0048beae00 100644 --- a/cli/src/cli.h +++ b/cli/src/cli.h @@ -128,6 +128,8 @@ struct cli_local { } get_vol; dict_t *dict; + /* Marker for volume status all */ + gf_boolean_t all; #if (HAVE_LIB_XML) xmlTextWriterPtr writer; xmlBufferPtr buf; |