summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvra Sengupta <asengupt@redhat.com>2012-11-22 16:02:47 +0530
committerVijay Bellur <vbellur@redhat.com>2012-11-27 22:29:10 -0800
commit9e2aeea9242c04228049003bf8f878ea38af76da (patch)
treecb1616125697f27ee4d53a6db9d790ee79037f73
parent22f0be5a608bdfc5d2bc3d37f19689367966a6dd (diff)
cli: XML output for "gluster volume geo-replication status"
Change-Id: I1a64bd5eb9b1040a2a2d9b97bfe9cc756835596e BUG: 864506 Signed-off-by: Avra Sengupta <asengupt@redhat.com> Reviewed-on: http://review.gluster.org/4227 Reviewed-by: Kaushal M <kaushal@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r--cli/src/cli-xml-output.c80
-rwxr-xr-xtests/bugs/bug-864506.t33
2 files changed, 112 insertions, 1 deletions
diff --git a/cli/src/cli-xml-output.c b/cli/src/cli-xml-output.c
index 47c0854b2ed..3e8bbdd4fbf 100644
--- a/cli/src/cli-xml-output.c
+++ b/cli/src/cli-xml-output.c
@@ -3170,6 +3170,82 @@ out:
}
int
+cli_xml_output_vol_gsync_status (dict_t *dict, xmlTextWriterPtr writer)
+{
+ char master_key[PATH_MAX] = "";
+ char slave_key[PATH_MAX] = "";
+ char status_key[PATH_MAX] = "";
+ char node_key[PATH_MAX] = "";
+ char *master = NULL;
+ char *slave = NULL;
+ char *status = NULL;
+ char *node = NULL;
+ int ret = -1;
+ int gsync_count = 0;
+ int i = 1;
+
+ ret = dict_get_int32 (dict, "gsync-count", &gsync_count);
+ if (ret)
+ goto out;
+
+ for (i=1; i <= gsync_count; i++) {
+ snprintf (node_key, sizeof(node_key), "node%d", i);
+ snprintf (master_key, sizeof(master_key), "master%d", i);
+ snprintf (slave_key, sizeof(slave_key), "slave%d", i);
+ snprintf (status_key, sizeof(status_key), "status%d", i);
+
+ ret = dict_get_str (dict, node_key, &node);
+ if (ret)
+ goto out;
+
+ ret = dict_get_str (dict, master_key, &master);
+ if (ret)
+ goto out;
+
+ ret = dict_get_str (dict, slave_key, &slave);
+ if (ret)
+ goto out;
+
+ ret = dict_get_str (dict, status_key, &status);
+ if (ret)
+ goto out;
+
+ /* <pair> */
+ ret = xmlTextWriterStartElement (writer, (xmlChar *)"pair");
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
+ ret = xmlTextWriterWriteFormatElement (writer,
+ (xmlChar *)"node",
+ "%s", node);
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
+ ret = xmlTextWriterWriteFormatElement (writer,
+ (xmlChar *)"master",
+ "%s", master);
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
+ ret = xmlTextWriterWriteFormatElement (writer,
+ (xmlChar *)"slave",
+ "%s", slave);
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
+ ret = xmlTextWriterWriteFormatElement (writer,
+ (xmlChar *)"status",
+ "%s", status);
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
+ /* </pair> */
+ ret = xmlTextWriterEndElement (writer);
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
+ }
+
+out:
+ gf_log ("cli",GF_LOG_DEBUG, "Returning %d", ret);
+ return ret;
+}
+
+int
cli_xml_output_vol_gsync (dict_t *dict, int op_ret, int op_errno,
char *op_errstr)
{
@@ -3227,8 +3303,10 @@ cli_xml_output_vol_gsync (dict_t *dict, int op_ret, int op_errno,
break;
case GF_GSYNC_OPTION_TYPE_CONFIG:
+ break;
case GF_GSYNC_OPTION_TYPE_STATUS:
- // TODO: XML output for these two types.
+ ret = cli_xml_output_vol_gsync_status(dict, writer);
+ break;
default:
ret = 0;
break;
diff --git a/tests/bugs/bug-864506.t b/tests/bugs/bug-864506.t
new file mode 100755
index 00000000000..c281f381124
--- /dev/null
+++ b/tests/bugs/bug-864506.t
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+. $(dirname $0)/../include.rc
+
+cleanup;
+
+
+TEST glusterd
+TEST pidof glusterd
+TEST $CLI volume create $V0 $H0:$B0/brick0
+TEST $CLI volume start $V0
+
+TEST "mkdir $B0/slave"
+
+TEST "$CLI volume geo-replication $V0 $B0/slave start --xml | xmllint --format -"
+
+TEST "$CLI volume geo-replication $V0 $B0/slave2 start --xml | xmllint --format -"
+
+TEST "$CLI volume geo-replication status --xml | xmllint --format -"
+
+TEST "$CLI volume geo-replication $V0 $B0/slave status --xml | xmllint --format -"
+
+TEST "$CLI volume geo-replication $V0 $B0/slave2 status --xml | xmllint --format -"
+
+TEST "$CLI volume geo-replication $V0 $B0/slave stop --xml | xmllint --format -"
+
+TEST "$CLI volume geo-replication $V0 $B0/slave2 stop --xml | xmllint --format -"
+
+TEST $CLI volume stop $V0
+
+TEST "rmdir $B0/slave"
+
+cleanup;