diff options
author | Aravinda VK <avishwan@redhat.com> | 2013-09-25 12:04:11 +0530 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2013-10-03 21:12:21 -0700 |
commit | 59b4e379e6d56af4828738c966b80c313415f632 (patch) | |
tree | 01e7b2546583c2648eefa590986e1ab2c4a20559 /cli | |
parent | a5ef7bc7de744d1324ddf63207b1172d11086441 (diff) |
cli: skipped tag in xml output of rebalance/remove-brick status
Skipped files count is available in CLI output of rebalance status
and remove-brick status, but not available in xml output.
Example output:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<cliOutput>
<opRet>0</opRet>
<opErrno>0</opErrno>
<opErrstr/>
<volRebalance>
<op>3</op>
<nodeCount>1</nodeCount>
<node>
<nodeName>localhost</nodeName>
<files>0</files>
<size>0</size>
<lookups>0</lookups>
<failures>0</failures>
<skipped>0</skipped>
<status>0</status>
<statusStr>completed</statusStr>
</node>
<aggregate>
<files>0</files>
<size>0</size>
<lookups>0</lookups>
<failures>0</failures>
<skipped>0</skipped>
<status>0</status>
<statusStr>completed</statusStr>
</aggregate>
</volRebalance>
</cliOutput>
BUG: 1012772
Change-Id: I05191293403e66e0d681f0cd0422aa3c78a2d91d
Signed-off-by: Aravinda VK <avishwan@redhat.com>
Reviewed-on: http://review.gluster.org/6000
Reviewed-by: Kaushal M <kaushal@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'cli')
-rw-r--r-- | cli/src/cli-xml-output.c | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/cli/src/cli-xml-output.c b/cli/src/cli-xml-output.c index d9e972d04f5..b57a17a8961 100644 --- a/cli/src/cli-xml-output.c +++ b/cli/src/cli-xml-output.c @@ -14,6 +14,12 @@ #include "compat.h" #include "syscall.h" + +enum gf_task_types { + GF_TASK_TYPE_REBALANCE, + GF_TASK_TYPE_REMOVE_BRICK +}; + /* * IMPORTANT NOTE: * All exported functions in this file which use libxml need use a @@ -2977,7 +2983,8 @@ out: #if (HAVE_LIB_XML) /* Used for rebalance stop/status, remove-brick status */ int -cli_xml_output_vol_rebalance_status (xmlTextWriterPtr writer, dict_t *dict) +cli_xml_output_vol_rebalance_status (xmlTextWriterPtr writer, dict_t *dict, + enum gf_task_types task_type) { int ret = -1; int count = 0; @@ -2987,10 +2994,12 @@ cli_xml_output_vol_rebalance_status (xmlTextWriterPtr writer, dict_t *dict) uint64_t lookups = 0; int status_rcd = 0; uint64_t failures = 0; + uint64_t skipped = 0; uint64_t total_files = 0; uint64_t total_size = 0; uint64_t total_lookups = 0; uint64_t total_failures = 0; + uint64_t total_skipped = 0; char key[1024] = {0,}; int i = 0; int overall_status = -1; @@ -3068,6 +3077,27 @@ cli_xml_output_vol_rebalance_status (xmlTextWriterPtr writer, dict_t *dict) "%"PRIu64, failures); XML_RET_CHECK_AND_GOTO (ret, out); + /* skipped-%d is not available for remove brick in dict, + so using failures as skipped count in case of remove-brick + similar to logic used in CLI(non xml output) */ + if (task_type == GF_TASK_TYPE_REBALANCE) { + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "skipped-%d", i); + } + else { + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "failures-%d", i); + } + + ret = dict_get_uint64 (dict, key, &skipped); + if (ret) + goto out; + total_skipped += skipped; + ret = xmlTextWriterWriteFormatElement (writer, + (xmlChar *)"skipped", + "%"PRIu64, skipped); + XML_RET_CHECK_AND_GOTO (ret, out); + memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "status-%d", i); ret = dict_get_int32 (dict, key, &status_rcd); @@ -3116,6 +3146,10 @@ cli_xml_output_vol_rebalance_status (xmlTextWriterPtr writer, dict_t *dict) "%"PRIu64, total_failures); XML_RET_CHECK_AND_GOTO (ret, out); + ret = xmlTextWriterWriteFormatElement (writer,(xmlChar *)"skipped", + "%"PRIu64, total_skipped); + XML_RET_CHECK_AND_GOTO (ret, out); + ret = xmlTextWriterWriteFormatElement (writer,(xmlChar *)"status", "%d", overall_status); XML_RET_CHECK_AND_GOTO (ret, out); @@ -3170,7 +3204,8 @@ cli_xml_output_vol_rebalance (gf_cli_defrag_type op, dict_t *dict, int op_ret, XML_RET_CHECK_AND_GOTO (ret, out); if ((GF_DEFRAG_CMD_STOP == op) || (GF_DEFRAG_CMD_STATUS == op)) { - ret = cli_xml_output_vol_rebalance_status (writer, dict); + ret = cli_xml_output_vol_rebalance_status (writer, dict, + GF_TASK_TYPE_REBALANCE); if (ret) goto out; } @@ -3221,7 +3256,8 @@ cli_xml_output_vol_remove_brick (gf_boolean_t status_op, dict_t *dict, } if (status_op) { - ret = cli_xml_output_vol_rebalance_status (writer, dict); + ret = cli_xml_output_vol_rebalance_status (writer, dict, + GF_TASK_TYPE_REMOVE_BRICK); if (ret) goto out; } |