summaryrefslogtreecommitdiffstats
path: root/cli/src/cli-cmd-parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'cli/src/cli-cmd-parser.c')
-rw-r--r--cli/src/cli-cmd-parser.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index 79569d8c8..d576e1133 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -3067,7 +3067,8 @@ out:
}
int32_t
-cli_snap_config_parse (const char **words, int wordcount, dict_t *options)
+cli_snap_config_parse (const char **words, int wordcount, dict_t *options,
+ struct cli_state *state)
{
char *volname = NULL;
int ret = -1;
@@ -3075,9 +3076,16 @@ cli_snap_config_parse (const char **words, int wordcount, dict_t *options)
char *value = NULL;
uint64_t limit = 0;
gf1_cli_snapshot type = GF_SNAP_OPTION_TYPE_NONE;
+ gf_answer_t answer = GF_ANSWER_NO;
+ const char *question = "Changing snapshot-max-limit"
+ " will lead deletion of snap"
+ "shots if they exceed the "
+ "new limit.\nDo you want to"
+ " continue?";
GF_ASSERT (words);
GF_ASSERT (options);
+ GF_ASSERT (state);
if ((wordcount != 3) && (wordcount != 5))
goto out;
@@ -3137,6 +3145,12 @@ cli_snap_config_parse (const char **words, int wordcount, dict_t *options)
if (ret)
goto out;
+ answer = cli_cmd_get_confirmation (state, question);
+
+ if (GF_ANSWER_NO == answer) {
+ ret = -1;
+ goto out;
+ }
out:
return ret;
}
@@ -3241,7 +3255,8 @@ out:
int32_t
-cli_cmd_snapshot_parse (const char **words, int wordcount, dict_t **options)
+cli_cmd_snapshot_parse (const char **words, int wordcount, dict_t **options,
+ struct cli_state *state)
{
int32_t ret = -1;
dict_t *dict = NULL;
@@ -3255,6 +3270,7 @@ cli_cmd_snapshot_parse (const char **words, int wordcount, dict_t **options)
GF_ASSERT (words);
GF_ASSERT (options);
+ GF_ASSERT (state);
dict = dict_new ();
if (!dict)
@@ -3354,7 +3370,12 @@ cli_cmd_snapshot_parse (const char **words, int wordcount, dict_t **options)
type = GF_SNAP_OPTION_TYPE_CONFIG;
- ret = cli_snap_config_parse (words, wordcount, dict);
+ ret = cli_snap_config_parse (words, wordcount, dict, state);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR,
+ "config command parsing failed.");
+ goto out;
+ }
} else {
gf_log ("", GF_LOG_ERROR, "Opword Mismatch");
goto out;