From da882973235c7d2fc2ad20c030dadd327366a58c Mon Sep 17 00:00:00 2001 From: Hari Gowtham Date: Wed, 5 Aug 2015 19:30:20 +0530 Subject: xml/tiering: enhance xml output for tiering status related cli commands 0 0 34f47e29-2193-4a86-9b1e-c7e56bdae3d4 7 1 localhost 0 0 in progress Change-Id: I61083f7b9b0b3bd840982b8c5d6ea4b42e27c9b3 BUG: 1252737 Signed-off-by: Hari Gowtham Reviewed-on: http://review.gluster.org/11890 Tested-by: NetBSD Build System Reviewed-by: mohammed rafi kc Reviewed-by: Dan Lambright --- cli/src/cli-xml-output.c | 107 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) (limited to 'cli') 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 @@ -3321,6 +3321,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) -- cgit