summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiels de Vos <ndevos@redhat.com>2014-07-18 19:05:26 +0200
committerNiels de Vos <ndevos@redhat.com>2014-07-21 00:11:19 -0700
commitd5f72dc49604aec2643d92a1b4e321c532ef8d05 (patch)
tree385c2a4b0afa246009d5434acf79a333e2770800
parent09692a4c1645b0783ddaf83d264c3b148476f937 (diff)
cli: Fix xml output for volume statusv3.5.2beta1
The XML output for volume status was malformed when one of the nodes is down, leading to outputs like ------- <node> <node> <hostname>NFS Server</hostname> <path>localhost</path> <peerid>63ca3d2f-8c1f-4b84-b797-b4baddab81fb</peerid> <status>1</status> <port>2049</port> <pid>2130</pid> </node> ----- This was happening because we were starting the <node> element before determining if node was present, and were not closing it or clearing it when not finding the node in the dict. To fix this, the <node> element is only started once a node has been found in the dict. Cherry picked from commit 2ba42d07eb967472227eb0a93e4ca2cac7a197b5: > Change-Id: I6b6205f14b27a69adb95d85db7b48999aa48d400 > BUG: 1046020 > Signed-off-by: Kaushal M <kaushal@redhat.com> > Reviewed-on: http://review.gluster.org/6571 > Reviewed-by: Aravinda VK <avishwan@redhat.com> > Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com> > Tested-by: Gluster Build System <jenkins@build.gluster.com> > Reviewed-by: Vijay Bellur <vbellur@redhat.com> Change-Id: I6b6205f14b27a69adb95d85db7b48999aa48d400 BUG: 1117241 Signed-off-by: Niels de Vos <ndevos@redhat.com> Reviewed-on: http://review.gluster.org/8334 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Kaushal M <kaushal@redhat.com>
-rw-r--r--cli/src/cli-xml-output.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/cli/src/cli-xml-output.c b/cli/src/cli-xml-output.c
index e6cdf5f84f9..8def609459e 100644
--- a/cli/src/cli-xml-output.c
+++ b/cli/src/cli-xml-output.c
@@ -251,6 +251,11 @@ cli_xml_output_vol_status_common (xmlTextWriterPtr writer, dict_t *dict,
}
*node_present = _gf_true;
+ /* <node>
+ * will be closed in the calling function cli_xml_output_vol_status()*/
+ ret = xmlTextWriterStartElement (writer, (xmlChar *)"node");
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"hostname",
"%s", hostname);
XML_RET_CHECK_AND_GOTO (ret, out);
@@ -1662,11 +1667,6 @@ cli_xml_output_vol_status (cli_local_t *local, dict_t *dict)
index_max = brick_index_max + other_count;
for (i = 0; i <= index_max; i++) {
- /* <node> */
- ret = xmlTextWriterStartElement (local->writer,
- (xmlChar *)"node");
- XML_RET_CHECK_AND_GOTO (ret, out);
-
ret = cli_xml_output_vol_status_common (local->writer, dict, i,
&online, &node_present);
if (ret) {
@@ -1732,7 +1732,8 @@ cli_xml_output_vol_status (cli_local_t *local, dict_t *dict)
break;
}
- /* </node> */
+
+ /* </node> was opened in cli_xml_output_vol_status_common()*/
ret = xmlTextWriterEndElement (local->writer);
XML_RET_CHECK_AND_GOTO (ret, out);
}