summaryrefslogtreecommitdiffstats
path: root/cli/src/cli-xml-output.c
diff options
context:
space:
mode:
Diffstat (limited to 'cli/src/cli-xml-output.c')
-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) {