summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVijaikumar M <vmallika@redhat.com>2014-01-15 14:28:44 +0530
committerVijaikumar M <vmallika@redhat.com>2014-01-15 14:30:35 +0530
commitf05bd50f2de5001cbd7b45e3c4164b6d131b17b0 (patch)
treed6c736248d8964f317fd24c642a2fb729c7f8ab9
parente17b100f73b3204867d70f0f95a9b2de9c13b467 (diff)
glusterd/snapshot: A Warning must be displayed before the snapshot is deleted
Currently, on deleting snapshot , there is no warning message displayed to the user. A Warning must be displayed before the snapshot is deleted as follows: Deleting snap will erase all information about the snap. Do you want to continue? (y/n) Change-Id: I60f4f346da36b6564576c7482f5989a17d4bb5e1 BUG: 1048216 Signed-off-by: Vijaikumar M <vmallika@redhat.com>
-rw-r--r--cli/src/cli-cmd-parser.c39
-rw-r--r--cli/src/cli-cmd-snapshot.c10
2 files changed, 40 insertions, 9 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index 1059ea90e..6abd97ce7 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -3178,6 +3178,11 @@ out:
return ret;
}
+/* function cli_snap_config_parse
+ return value: -1 on failure
+ 1 if user cancels the operation
+ 0 on success
+*/
int32_t
cli_snap_config_parse (const char **words, int wordcount, dict_t *options,
struct cli_state *state)
@@ -3291,7 +3296,9 @@ cli_snap_config_parse (const char **words, int wordcount, dict_t *options,
answer = cli_cmd_get_confirmation (state,
conf_vals->question);
if (GF_ANSWER_NO == answer) {
- ret = -1;
+ ret = 1;
+ gf_log ("", GF_LOG_DEBUG, "User cancelled "
+ "snapshot config operation");
goto out;
}
}
@@ -3306,15 +3313,23 @@ out:
also should be given in the command. If cg should be removed,
then volume name is not necessary.
"gluster snapshot delete (<volname> -s <snapname> | -c <cgname>)"
+ return value: -1 on failure
+ 1 if user cancels the operation
+ 0 on success
*/
int32_t
cli_snap_remove_parse (dict_t *dict, const char **words, int wordcount,
- unsigned int cmdi)
+ unsigned int cmdi, struct cli_state *state)
{
uint32_t name_opt_loc = 0;
int32_t ret = -1;
uint32_t i = 0;
gf_boolean_t is_cg = _gf_false;
+ const char *question = NULL;
+ gf_answer_t answer = GF_ANSWER_NO;
+
+ question = "Deleting snap will erase all information about the snap. "
+ "Do you want to continue?";
GF_ASSERT (dict);
GF_ASSERT (words);
@@ -3389,6 +3404,14 @@ cli_snap_remove_parse (dict_t *dict, const char **words, int wordcount,
}
}
+ answer = cli_cmd_get_confirmation (state, question);
+ if (GF_ANSWER_NO == answer) {
+ ret = 1;
+ gf_log ("", GF_LOG_DEBUG, "User cancelled "
+ "snapshot delete operation");
+ goto out;
+ }
+
out:
return ret;
}
@@ -3607,10 +3630,11 @@ cli_cmd_snapshot_parse (const char **words, int wordcount, dict_t **options,
cmdi = 2;
ret = cli_snap_remove_parse (dict, words,
- wordcount, cmdi);
+ wordcount, cmdi, state);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
- "remove command parsing failed.");
+ if (ret < 0)
+ gf_log ("", GF_LOG_ERROR,
+ "remove command parsing failed.");
goto out;
}
break;
@@ -3622,8 +3646,9 @@ cli_cmd_snapshot_parse (const char **words, int wordcount, dict_t **options,
ret = cli_snap_config_parse (words, wordcount, dict,
state);
if (ret) {
- gf_log ("cli", GF_LOG_ERROR,
- "config command parsing failed.");
+ if (ret < 0)
+ gf_log ("cli", GF_LOG_ERROR,
+ "config command parsing failed.");
goto out;
}
break;
diff --git a/cli/src/cli-cmd-snapshot.c b/cli/src/cli-cmd-snapshot.c
index 6d31dc2d5..f16e68dd6 100644
--- a/cli/src/cli-cmd-snapshot.c
+++ b/cli/src/cli-cmd-snapshot.c
@@ -53,8 +53,14 @@ 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, state);
if (ret) {
- cli_usage_out (word->pattern);
- parse_err = 1;
+ if (ret < 0) {
+ cli_usage_out (word->pattern);
+ parse_err = 1;
+ }
+ else {
+ /* User might have cancelled the snapshot operation */
+ ret = 0;
+ }
goto out;
}