From f6612dbb66166960e353b2a8bded786f7aed62d9 Mon Sep 17 00:00:00 2001 From: shishir gowda Date: Thu, 31 Oct 2013 12:02:32 +0530 Subject: cli/snapshot: Ask user to confirm change of snap max limit Change-Id: I6fd89a98c4a111bb6cd3e4d3c2b3d6f783661c27 Signed-off-by: shishir gowda --- cli/src/cli-cmd-parser.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'cli/src/cli-cmd-parser.c') diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 44c497977..2b0633eeb 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -3164,7 +3164,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; @@ -3172,9 +3173,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; @@ -3234,6 +3242,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; } @@ -3338,7 +3352,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; @@ -3352,6 +3367,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) @@ -3451,7 +3467,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; -- cgit