diff options
author | Aravinda VK <avishwan@redhat.com> | 2013-10-22 14:09:44 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2013-10-24 05:20:41 -0700 |
commit | 71614ecbd96f65273d7a19bc62b1d918a8b36191 (patch) | |
tree | 9b0c7c49c2bd19bbfa90d009cd09b1588284b8e5 | |
parent | 45d6c6ba540beaaab2fd9d2703ef8b2ce0da0454 (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: I4f5128c3fa3b2b791bcbaf41ac7f229f80bfefe9
Signed-off-by: Aravinda VK <avishwan@redhat.com>
Reviewed-on: http://review.gluster.org/6000
Reviewed-by: Kaushal M <kaushal@redhat.com>
Reviewed-on: http://review.gluster.org/6119
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
-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 81550ee689a..b9f4cfe46db 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 @@ -2965,7 +2971,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; @@ -2975,10 +2982,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; @@ -3058,6 +3067,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); @@ -3121,6 +3151,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); @@ -3179,7 +3213,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; } @@ -3230,7 +3265,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; } |