diff options
author | Hari Gowtham <hgowtham@redhat.com> | 2015-08-05 19:30:20 +0530 |
---|---|---|
committer | Dan Lambright <dlambrig@redhat.com> | 2015-09-07 17:57:33 -0700 |
commit | da882973235c7d2fc2ad20c030dadd327366a58c (patch) | |
tree | 6aa9cf7ac25da5081d2e58408d562048c0c9bf77 /cli/src | |
parent | 7b6183c36ebfe020b724c95b018a8cd535e1ecdd (diff) |
xml/tiering: enhance xml output for tiering status related cli commands
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<cliOutput>
<opRet>0</opRet>
<opErrno>0</opErrno>
<opErrstr/>
<volRebalance>
<task-id>34f47e29-2193-4a86-9b1e-c7e56bdae3d4</task-id>
<op>7</op>
<nodeCount>1</nodeCount>
<node>
<nodeName>localhost</nodeName>
<promotedfiles>0</promotedfiles>
<demotedfiles>0</demotedfiles>
<statusStr>in progress</statusStr>
</node>
</volRebalance>
</cliOutput>
Change-Id: I61083f7b9b0b3bd840982b8c5d6ea4b42e27c9b3
BUG: 1252737
Signed-off-by: Hari Gowtham <hgowtham@redhat.com>
Reviewed-on: http://review.gluster.org/11890
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Reviewed-by: mohammed rafi kc <rkavunga@redhat.com>
Reviewed-by: Dan Lambright <dlambrig@redhat.com>
Diffstat (limited to 'cli/src')
-rw-r--r-- | cli/src/cli-xml-output.c | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/cli/src/cli-xml-output.c b/cli/src/cli-xml-output.c index fcbc72d51eb..327cd6c6ffd 100644 --- a/cli/src/cli-xml-output.c +++ b/cli/src/cli-xml-output.c @@ -3322,6 +3322,106 @@ out: #endif int +cli_xml_output_vol_tier_status (xmlTextWriterPtr writer, dict_t *dict, + enum gf_task_types task_type) +{ +#if (HAVE_LIB_XML) + + int ret = -1; + int count = 0; + char *node_name = NULL; + char *status_str = NULL; + uint64_t promoted = 0; + uint64_t demoted = 0; + int i = 1; + char key[1024] = {0,}; + gf_defrag_status_t status_rcd = GF_DEFRAG_STATUS_NOT_STARTED; + + + GF_VALIDATE_OR_GOTO ("cli", dict, out); + + ret = dict_get_int32 (dict, "count", &count); + if (ret) { + gf_log ("cli", GF_LOG_ERROR, "count not set"); + goto out; + } + + ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"nodeCount", + "%d", count); + XML_RET_CHECK_AND_GOTO (ret, out); + + while (i <= count) { + promoted = 0; + node_name = NULL; + demoted = 0; + + ret = xmlTextWriterStartElement (writer, (xmlChar *)"node"); + XML_RET_CHECK_AND_GOTO (ret, out); + + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "node-name-%d", i); + ret = dict_get_str (dict, key, &node_name); + if (ret) + goto out; + ret = xmlTextWriterWriteFormatElement (writer, + (xmlChar *)"nodeName", + "%s", node_name); + XML_RET_CHECK_AND_GOTO (ret, out); + + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "promoted-%d", i); + ret = dict_get_uint64 (dict, key, &promoted); + if (ret) + goto out; + ret = xmlTextWriterWriteFormatElement (writer, + (xmlChar *)"promoted" + "Files", "%"PRIu64, + promoted); + XML_RET_CHECK_AND_GOTO (ret, out); + + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "demoted-%d", i); + ret = dict_get_uint64 (dict, key, &demoted); + if (ret) + goto out; + ret = xmlTextWriterWriteFormatElement (writer, + (xmlChar *)"demoted" + "Files", "%"PRIu64, + demoted); + XML_RET_CHECK_AND_GOTO (ret, out); + + memset (key, 0, 256); + snprintf (key, 256, "status-%d", i); + ret = dict_get_int32 (dict, key, (int32_t *)&status_rcd); + + status_str = cli_vol_task_status_str[status_rcd]; + + ret = xmlTextWriterWriteFormatElement (writer, + (xmlChar *)"statusStr", + "%s", status_str); + XML_RET_CHECK_AND_GOTO (ret, out); + + + ret = xmlTextWriterEndElement (writer); + XML_RET_CHECK_AND_GOTO (ret, out); + + i++; + } + +out: + gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret); + return ret; + +#else + return 0; + +#endif +} + + + + +int cli_xml_output_vol_rebalance (gf_cli_defrag_type op, dict_t *dict, int op_ret, int op_errno, char *op_errstr) { @@ -3355,7 +3455,14 @@ cli_xml_output_vol_rebalance (gf_cli_defrag_type op, dict_t *dict, int op_ret, "%d", op); XML_RET_CHECK_AND_GOTO (ret, out); + if (GF_DEFRAG_CMD_STATUS_TIER == op) { + ret = cli_xml_output_vol_tier_status (writer, + dict, GF_TASK_TYPE_REBALANCE); + if (ret) + goto out; + } if ((GF_DEFRAG_CMD_STOP == op) || (GF_DEFRAG_CMD_STATUS == op)) { + ret = cli_xml_output_vol_rebalance_status (writer, dict, GF_TASK_TYPE_REBALANCE); if (ret) |