diff options
author | vmallika <vmallika@redhat.com> | 2014-10-28 12:25:43 +0530 |
---|---|---|
committer | Raghavendra Bhat <raghavendra@redhat.com> | 2014-12-18 22:52:22 -0800 |
commit | df0ff94a64bd597e61f26a2a56297de7abf80a0f (patch) | |
tree | 163dfd82065add6b19ab32a1599dfb389d49911a /cli/src/cli-cmd-parser.c | |
parent | f0a90bf48135c480c41a71ef25f46619001a3116 (diff) |
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 <enable|disable>
Change-Id: I1911595c32beed43bb2fca4bf99f0d264b422513
BUG: 1170921
Signed-off-by: vmallika <vmallika@redhat.com>
Reviewed-on: http://review.gluster.org/8985
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Avra Sengupta <asengupt@redhat.com>
Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
Reviewed-by: Kaushal M <kaushal@redhat.com>
Signed-off-by: Sachin Pandit <spandit@redhat.com>
Reviewed-on: http://review.gluster.org/9241
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Diffstat (limited to 'cli/src/cli-cmd-parser.c')
-rw-r--r-- | cli/src/cli-cmd-parser.c | 51 |
1 files changed, 41 insertions, 10 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 27f1fec0df8..28888ba656d 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -278,7 +278,7 @@ cli_cmd_volume_create_parse (struct cli_state *state, const char **words, "description", "force", "snap-max-hard-limit", "snap-max-soft-limit", "auto-delete", - NULL}; + "activate-on-create", NULL}; char *w = NULL; char *ptr = NULL; int op_count = 0; @@ -3868,8 +3868,7 @@ cli_snap_config_parse (const char **words, int wordcount, dict_t *dict, int8_t soft_limit = 0; int8_t config_type = -1; const char *question = NULL; - unsigned int cmdi = 2; - int8_t auto_delete = -1; + unsigned int cmdi = 2; /* cmdi is command index, here cmdi is "2" (gluster snapshot config)*/ GF_ASSERT (words); @@ -3892,7 +3891,8 @@ cli_snap_config_parse (const char **words, int wordcount, dict_t *dict, /* Check whether the 3rd word is volname */ if (strcmp (words[cmdi], "snap-max-hard-limit") != 0 && strcmp (words[cmdi], "snap-max-soft-limit") != 0 - && strcmp (words[cmdi], "auto-delete") != 0) { + && strcmp (words[cmdi], "auto-delete") != 0 + && strcmp (words[cmdi], "activate-on-create") != 0) { ret = dict_set_str (dict, "volname", (char *)words[cmdi]); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to set volname"); @@ -3950,10 +3950,12 @@ cli_snap_config_parse (const char **words, int wordcount, dict_t *dict, goto out; } soft_limit = 1; - goto set; } - if (hard_limit != 1 && (strcmp(words[cmdi], "auto-delete") == 0)) { + if (hard_limit || soft_limit) + goto set; + + if (strcmp(words[cmdi], "auto-delete") == 0) { if (vol_presence == 1) { ret = -1; cli_err ("As of now, auto-delete option cannot be set " @@ -3976,19 +3978,47 @@ cli_snap_config_parse (const char **words, int wordcount, dict_t *dict, "dictionary"); goto out; } - auto_delete = 1; if (++cmdi != wordcount) { ret = -1; gf_log ("cli", GF_LOG_ERROR, "Invalid Syntax"); goto out; } - } - else { + } else if (strcmp(words[cmdi], "activate-on-create") == 0) { + if (vol_presence == 1) { + ret = -1; + cli_err ("As of now, activate-on-create option " + "cannot be set to volumes"); + gf_log ("cli", GF_LOG_ERROR, "activate-on-create " + "option cannot be set to volumes"); + goto out; + } + + if (++cmdi >= wordcount) { + ret = -1; + gf_log ("cli", GF_LOG_ERROR, "Invalid Syntax"); + goto out; + } + + ret = dict_set_str (dict, "snap-activate-on-create", + (char *)words[cmdi]); + if (ret) { + gf_log ("cli", GF_LOG_ERROR, "Failed to set value " + "of activate-on-create in request dictionary"); + goto out; + } + + if (++cmdi != wordcount) { + ret = -1; + gf_log ("cli", GF_LOG_ERROR, "Invalid Syntax"); + goto out; + } + } else { ret = -1; gf_log ("cli", GF_LOG_ERROR, "Invalid Syntax"); goto out; } + ret = 0; /* Success */ set: @@ -3999,7 +4029,8 @@ set: goto out; } - if (config_type == GF_SNAP_CONFIG_TYPE_SET && auto_delete != 1) { + if (config_type == GF_SNAP_CONFIG_TYPE_SET && + (hard_limit || soft_limit)) { conf_vals = snap_confopt_vals; if (hard_limit && soft_limit) { question = conf_vals[GF_SNAP_CONFIG_SET_BOTH].question; |