From df0ff94a64bd597e61f26a2a56297de7abf80a0f Mon Sep 17 00:00:00 2001 From: vmallika Date: Tue, 28 Oct 2014 12:25:43 +0530 Subject: glusterd/snapshot: Snapshot should be deactivated when it is created. By default snapshot should be deactivated and this should be a configurable option. This behaviour can be configured by the command below: gluster snapshot config activate-on-create Change-Id: I1911595c32beed43bb2fca4bf99f0d264b422513 BUG: 1170921 Signed-off-by: vmallika Reviewed-on: http://review.gluster.org/8985 Tested-by: Gluster Build System Reviewed-by: Avra Sengupta Reviewed-by: Rajesh Joseph Reviewed-by: Kaushal M Signed-off-by: Sachin Pandit Reviewed-on: http://review.gluster.org/9241 Reviewed-by: Raghavendra Bhat --- cli/src/cli-xml-output.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'cli/src/cli-xml-output.c') diff --git a/cli/src/cli-xml-output.c b/cli/src/cli-xml-output.c index d0a72772085..90b184d9f3f 100644 --- a/cli/src/cli-xml-output.c +++ b/cli/src/cli-xml-output.c @@ -5164,7 +5164,7 @@ cli_xml_snapshot_config_show (xmlTextWriterPtr writer, ret = dict_get_str (dict, "auto-delete", &str_value); if (ret) { - gf_log ("cli", GF_LOG_ERROR, "Could not fetch auto-delet"); + gf_log ("cli", GF_LOG_ERROR, "Could not fetch auto-delete"); goto out; } @@ -5172,6 +5172,17 @@ cli_xml_snapshot_config_show (xmlTextWriterPtr writer, (xmlChar *) "autoDelete", "%s", str_value); XML_RET_CHECK_AND_GOTO (ret, out); + ret = dict_get_str (dict, "snap-activate-on-create", &str_value); + if (ret) { + gf_log ("cli", GF_LOG_ERROR, + "Could not fetch snap-activate-on-create-delete"); + goto out; + } + + ret = xmlTextWriterWriteFormatElement (writer, + (xmlChar *) "activateOnCreate", "%s", str_value); + XML_RET_CHECK_AND_GOTO (ret, out); + /* */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); @@ -5275,6 +5286,7 @@ cli_xml_snapshot_config_set (xmlTextWriterPtr writer, xmlDocPtr doc, uint64_t soft_limit = 0; char *volname = NULL; char *auto_delete = NULL; + char *snap_activate = NULL; GF_ASSERT (writer); GF_ASSERT (doc); @@ -5285,12 +5297,13 @@ cli_xml_snapshot_config_set (xmlTextWriterPtr writer, xmlDocPtr doc, /* This is optional parameter therefore ignore the error */ ret = dict_get_uint64 (dict, "snap-max-soft-limit", &soft_limit); ret = dict_get_str (dict, "auto-delete", &auto_delete); + ret = dict_get_str (dict, "snap-activate-on-create", &snap_activate); - if (!hard_limit && !soft_limit && !auto_delete) { + if (!hard_limit && !soft_limit && !auto_delete && !snap_activate) { ret = -1; gf_log ("cli", GF_LOG_ERROR, "At least one option from " - "snap-max-hard-limit, snap-max-soft-limit and " - "auto-delete should be set"); + "snap-max-hard-limit, snap-max-soft-limit, auto-delete" + " and snap-activate-on-create should be set"); goto out; } @@ -5333,6 +5346,12 @@ cli_xml_snapshot_config_set (xmlTextWriterPtr writer, xmlDocPtr doc, XML_RET_CHECK_AND_GOTO (ret, out); } + if (snap_activate) { + ret = xmlTextWriterWriteFormatElement (writer, + (xmlChar *) "activateOnCreate", "%s", snap_activate); + XML_RET_CHECK_AND_GOTO (ret, out); + } + /* or */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); -- cgit