diff options
Diffstat (limited to 'cli/src/cli-cmd-parser.c')
-rw-r--r-- | cli/src/cli-cmd-parser.c | 57 |
1 files changed, 53 insertions, 4 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 7c6e3176dc6..d855dbf8a0a 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -197,7 +197,8 @@ cli_cmd_volume_create_parse (const char **words, int wordcount, dict_t **options "end-volume", "all", "volume_not_in_ring", "description", "force", "snap-max-hard-limit", - "snap-max-soft-limit", NULL}; + "snap-max-soft-limit", "auto-delete", + NULL}; char *w = NULL; int op_count = 0; int32_t replica_count = 1; @@ -3612,6 +3613,7 @@ cli_snap_config_parse (const char **words, int wordcount, dict_t *dict, int8_t config_type = -1; const char *question = NULL; unsigned int cmdi = 2; + int8_t auto_delete = -1; /* cmdi is command index, here cmdi is "2" (gluster snapshot config)*/ GF_ASSERT (words); @@ -3630,9 +3632,11 @@ cli_snap_config_parse (const char **words, int wordcount, dict_t *dict, goto set; } + /* auto-delete cannot be a volume name */ /* 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], "snap-max-soft-limit") != 0 + && strcmp (words[cmdi], "auto-delete") != 0) { ret = dict_set_str (dict, "volname", (char *)words[cmdi]); if (ret) { gf_log ("cli", GF_LOG_ERROR, "Failed to set volname"); @@ -3690,7 +3694,52 @@ cli_snap_config_parse (const char **words, int wordcount, dict_t *dict, goto out; } soft_limit = 1; - } else { + goto set; + } + + if (hard_limit != 1 && (strcmp(words[cmdi], "auto-delete") == 0)) { + if (vol_presence == 1) { + ret = -1; + cli_err ("As of now, auto-delete option cannot be set " + "to volumes"); + gf_log ("cli", GF_LOG_ERROR, "auto-delete option " + "cannot be set to volumes"); + goto out; + } + + if (++cmdi >= wordcount) { + ret = -1; + gf_log ("cli", GF_LOG_ERROR, "Invalid Syntax"); + goto out; + } + + if ((strcmp (words[cmdi], "enable") == 0) || + (strcmp (words[cmdi], "disable") == 0)) { + ret = dict_set_str (dict, "auto-delete", + (char *)words[cmdi]); + if (ret) { + gf_log ("cli", GF_LOG_ERROR, "Failed to set " + "value of auto-delete in request " + "dictionary"); + goto out; + } + auto_delete = 1; + } else { + ret = -1; + cli_err ("Please enter a valid value (enable/disable) " + "for auto-delete"); + gf_log ("cli", GF_LOG_ERROR, "Invalid value for " + "auto-delete"); + 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; @@ -3705,7 +3754,7 @@ set: goto out; } - if (config_type == GF_SNAP_CONFIG_TYPE_SET) { + if (config_type == GF_SNAP_CONFIG_TYPE_SET && auto_delete != 1) { conf_vals = snap_confopt_vals; if (hard_limit && soft_limit) { question = conf_vals[GF_SNAP_CONFIG_SET_BOTH].question; |