summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorMohammed Rafi KC <rkavunga@redhat.com>2015-03-31 10:54:10 +0530
committerRajesh Joseph <rjoseph@redhat.com>2016-07-29 03:09:41 -0700
commit8ef81bf02c779e7d126a654bde28d319d0fa823d (patch)
treeca2d6e5e9b6b5415c49d765f2b853d7413e73d2d /cli
parent6c43efbb6b01726e450b71d274c3b45b56cc7916 (diff)
Snapshot/xml:xml output for snapshot clone
Snapshot clone is used to create a regular volume from snapshot. Currently snapshot clone is not supporting xml outout. This change introduce a xml output for snapshot clone command Change-Id: I417b480d36f9d84ee088004999b041c9619edd50 BUG: 1207604 Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com> Reviewed-on: http://review.gluster.org/10065 Reviewed-by: Avra Sengupta <asengupt@redhat.com> Tested-by: Avra Sengupta <asengupt@redhat.com> Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-xml-output.c74
1 files changed, 72 insertions, 2 deletions
diff --git a/cli/src/cli-xml-output.c b/cli/src/cli-xml-output.c
index d03ddb1239a..8ef12b9a3c9 100644
--- a/cli/src/cli-xml-output.c
+++ b/cli/src/cli-xml-output.c
@@ -4526,6 +4526,65 @@ out:
return ret;
}
+/* This function will generate snapshot clone output in xml format.
+ *
+ * @param writer xmlTextWriterPtr
+ * @param doc xmlDocPtr
+ * @param dict dict containing create output
+ *
+ * @return 0 on success and -1 on failure
+ */
+static int
+cli_xml_snapshot_clone (xmlTextWriterPtr writer, xmlDocPtr doc, dict_t *dict)
+{
+ int ret = -1;
+ char *str_value = NULL;
+
+ GF_VALIDATE_OR_GOTO ("cli", writer, out);
+ GF_VALIDATE_OR_GOTO ("cli", doc, out);
+ GF_VALIDATE_OR_GOTO ("cli", dict, out);
+
+ /* <CloneCreate> */
+ ret = xmlTextWriterStartElement (writer, (xmlChar *)"CloneCreate");
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
+ /* <volume> */
+ ret = xmlTextWriterStartElement (writer, (xmlChar *)"volume");
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
+ ret = dict_get_str (dict, "clonename", &str_value);
+ if (ret) {
+ gf_log ("cli", GF_LOG_ERROR, "Failed to get clone name");
+ goto out;
+ }
+ ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "name",
+ "%s", str_value);
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
+
+ ret = dict_get_str (dict, "snapuuid", &str_value);
+ if (ret) {
+ gf_log ("cli", GF_LOG_ERROR, "Failed to get clone uuid");
+ goto out;
+ }
+
+ ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *) "uuid",
+ "%s", str_value);
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
+ /* </volume> */
+ ret = xmlTextWriterEndElement (writer);
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
+ /* </CloneCreate> */
+ ret = xmlTextWriterEndElement (writer);
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
+ ret = 0;
+out:
+ return ret;
+}
+
/* This function will generate snapshot restore output in xml format.
*
@@ -5102,10 +5161,13 @@ cli_xml_snapshot_volume_status (xmlTextWriterPtr writer, xmlDocPtr doc,
ret = dict_get_str (dict, key, &buffer);
if (ret) {
- gf_log ("cli", GF_LOG_ERROR,
+ gf_log ("cli", GF_LOG_INFO,
"Unable to get Brick Running");
- goto out;
+ strcpy (buffer, "N/A");
}
+ ret = xmlTextWriterWriteFormatElement (writer,
+ (xmlChar *) "BrickRunning", "%s", buffer);
+ XML_RET_CHECK_AND_GOTO (ret, out);
snprintf (key, sizeof (key), "%s.brick%d.pid", keyprefix, i);
@@ -5955,6 +6017,14 @@ cli_xml_output_snapshot (int cmd_type, dict_t *dict, int op_ret,
goto out;
}
break;
+ case GF_SNAP_OPTION_TYPE_CLONE:
+ ret = cli_xml_snapshot_clone (writer, doc, dict);
+ if (ret) {
+ gf_log ("cli", GF_LOG_ERROR, "Failed to create "
+ "xml output for snapshot clone command");
+ goto out;
+ }
+ break;
case GF_SNAP_OPTION_TYPE_RESTORE:
ret = cli_xml_snapshot_restore (writer, doc, dict);
if (ret) {