From 7d9bc0d21408c31651a65a6ec0e67c3b8acd0fde Mon Sep 17 00:00:00 2001 From: Kaushal M Date: Wed, 4 Sep 2013 13:06:57 +0530 Subject: cli: Fix 'status all' xml output when volumes are not started CLI now only outputs one XML document for 'status all' only containing those volumes which are started. BUG: 1004218 Change-Id: Id4130fe59b3b74475d8bd1cc8134ac59a28f1b7e Signed-off-by: Kaushal M Reviewed-on: http://review.gluster.org/5773 Reviewed-by: Vijay Bellur Tested-by: Gluster Build System --- cli/src/cli-rpc-ops.c | 22 ++++++++++++---------- tests/bugs/bug-1004218.t | 26 ++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 10 deletions(-) create mode 100644 tests/bugs/bug-1004218.t diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 74b7ac0c9..a773056c3 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -6406,10 +6406,12 @@ gf_cli_status_cbk (struct rpc_req *req, struct iovec *iov, "status information."); 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; + if (!local->all) + cli_xml_output_str ("volStatus", msg, + rsp.op_ret, rsp.op_errno, + rsp.op_errstr); + ret = 0; + goto out; } cli_err ("%s", msg); @@ -6677,12 +6679,6 @@ gf_cli_status_volume_all (call_frame_t *frame, xlator_t *this, void *data) goto out; } - if (vol_count == 0) { - cli_err ("No volumes present"); - ret = 0; - goto out; - } - /* remove the "all" flag in cmd */ cmd &= ~GF_CLI_STATUS_ALL; cmd |= GF_CLI_STATUS_VOL; @@ -6697,6 +6693,12 @@ gf_cli_status_volume_all (call_frame_t *frame, xlator_t *this, void *data) } } + if (vol_count == 0 && !(global_state->mode & GLUSTER_MODE_XML)) { + cli_err ("No volumes present"); + ret = 0; + goto out; + } + for (i = 0; i < vol_count; i++) { dict = dict_new (); diff --git a/tests/bugs/bug-1004218.t b/tests/bugs/bug-1004218.t new file mode 100644 index 000000000..17eb3c65b --- /dev/null +++ b/tests/bugs/bug-1004218.t @@ -0,0 +1,26 @@ +#!/bin/bash + +# Test if only a single xml document is generated by 'status all' +# when a volume is not started + +. $(dirname $0)/../include.rc + +cleanup; + +TEST glusterd + +TEST $CLI volume create ${V0}1 $H0:$B0/${V0}1{1,2} +TEST $CLI volume create ${V0}2 $H0:$B0/${V0}2{1,2} + +TEST $CLI volume start ${V0}1 + +function test_status_all () +{ + $CLI volume status all --xml | xmllint -format - +} + +TEST test_status_all + +TEST $CLI volume stop ${V0}1 + +cleanup -- cgit