summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorshishir gowda <sgowda@redhat.com>2013-10-31 12:02:32 +0530
committershishir gowda <sgowda@redhat.com>2013-11-15 14:45:14 +0530
commitf6612dbb66166960e353b2a8bded786f7aed62d9 (patch)
tree59753ea8cba63a04cd73b939f39fff3b92101029 /cli
parent3b4bc185024c905dc321b90d7972c3efecf45d01 (diff)
cli/snapshot: Ask user to confirm change of snap max limit
Change-Id: I6fd89a98c4a111bb6cd3e4d3c2b3d6f783661c27 Signed-off-by: shishir gowda <sgowda@redhat.com>
Diffstat (limited to 'cli')
-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 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;
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 65f9b857f..3d987a8bc 100644
--- a/cli/src/cli.h
+++ b/cli/src/cli.h
@@ -389,6 +389,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__ */