summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRajesh Joseph <rjoseph@redhat.com>2014-01-15 01:10:39 -0800
committerGerrit Code Review <review@dev.gluster.org>2014-01-15 01:10:39 -0800
commit0473ec32d337d54262643a44c7ff0c42e57a0ab1 (patch)
tree1b9b18639c801f8242f01aab405e2018ae591c03
parent6350f623853acf82d7d09a89c79a4ab5d6655fff (diff)
parentf05bd50f2de5001cbd7b45e3c4164b6d131b17b0 (diff)
Merge "glusterd/snapshot: A Warning must be displayed before the snapshot is deleted" into development
-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 1059ea9..6abd97c 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 6d31dc2..f16e68d 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;
}