summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshishir gowda <sgowda@redhat.com>2013-10-31 12:02:32 +0530
committershishir gowda <sgowda@redhat.com>2013-11-06 10:19:09 +0530
commita1941b9a20635b2fa5d041e19cc38e367862cdca (patch)
tree442714cc8c4071965f8cd0ec5397e6d61b429b17
parentdac1a4cfcd117a18ceefd0bb1d5c6a5f35689329 (diff)
cli/snapshot: Ask user to confirm change of snap max limit
Change-Id: I6fd89a98c4a111bb6cd3e4d3c2b3d6f783661c27 Signed-off-by: shishir gowda <sgowda@redhat.com>
-rw-r--r--cli/src/cli-cmd-parser.c27
-rw-r--r--cli/src/cli-cmd-snapshot.c2
-rw-r--r--cli/src/cli.h3
3 files changed, 27 insertions, 5 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;
diff --git a/cli/src/cli-cmd-snapshot.c b/cli/src/cli-cmd-snapshot.c
index 9f52ab01b..b3bc98abf 100644
--- a/cli/src/cli-cmd-snapshot.c
+++ b/cli/src/cli-cmd-snapshot.c
@@ -51,7 +51,7 @@ cli_cmd_snapshot_cbk (struct cli_state *state, struct cli_cmd_word *word,
}
/* Parses the command entered by the user */
- ret = cli_cmd_snapshot_parse (words, wordcount, &options);
+ ret = cli_cmd_snapshot_parse (words, wordcount, &options, state);
if (ret) {
cli_usage_out (word->pattern);
parse_err = 1;
diff --git a/cli/src/cli.h b/cli/src/cli.h
index 90ac2482c..4bc482628 100644
--- a/cli/src/cli.h
+++ b/cli/src/cli.h
@@ -398,6 +398,7 @@ char *
is_server_debug_xlator (void *myframe);
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);
#endif /* __CLI_H__ */