summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSachin Pandit <spandit@redhat.com>2014-08-25 05:42:38 +0530
committerKaushal M <kaushal@redhat.com>2014-08-27 21:49:21 -0700
commit92d1ae829ce5dfca7af2fdb33f10305732028602 (patch)
tree8b00b408c987a14ff9785c3a37a9e920f106e9b5
parentf56558224423e3af92aa08aa702dbc8cbdc0c55b (diff)
cli/snapshot : Add confirmation dialog to snapshot restore operation
When restoring a volume, the user is not prompted for confirmation. Since restoring a volume rolls back the data to a previous point in time, there is the potential for updates to be lost. Hence it is better to display a confirmation dialogue during snapshot restore operation. Change-Id: I7b23eaeb43ad2aafa508e2ca5750d9b0fc7d6e36 BUG: 1133426 Signed-off-by: Sachin Pandit <spandit@redhat.com> Reviewed-on: http://review.gluster.org/8525 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijaikumar Mallikarjuna <vmallika@redhat.com> Reviewed-by: Rajesh Joseph <rjoseph@redhat.com> Reviewed-by: Kaushal M <kaushal@redhat.com>
-rw-r--r--cli/src/cli-cmd-parser.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index 6e30a7094a8..27f1fec0df8 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -3500,10 +3500,13 @@ out:
* 0 on success
*/
int
-cli_snap_restore_parse (dict_t *dict, const char **words, int wordcount)
+cli_snap_restore_parse (dict_t *dict, const char **words, int wordcount,
+ struct cli_state *state)
{
int ret = -1;
+ const char *question = NULL;
+ gf_answer_t answer = GF_ANSWER_NO;
GF_ASSERT (words);
GF_ASSERT (dict);
@@ -3519,6 +3522,18 @@ cli_snap_restore_parse (dict_t *dict, const char **words, int wordcount)
words[2]);
goto out;
}
+
+ question = "Restore operation will replace the "
+ "original volume with the snapshotted volume. "
+ "Do you still want to continue?";
+
+ answer = cli_cmd_get_confirmation (state, question);
+ if (GF_ANSWER_NO == answer) {
+ ret = 1;
+ gf_log ("cli", GF_LOG_ERROR, "User cancelled a snapshot "
+ "restore operation for snap %s", (char *)words[2]);
+ goto out;
+ }
out:
return ret;
}
@@ -4215,13 +4230,14 @@ cli_cmd_snapshot_parse (const char **words, int wordcount, dict_t **options,
/* Syntax:
* snapshot restore <snapname>
*/
- ret = cli_snap_restore_parse (dict, words, wordcount);
+ ret = cli_snap_restore_parse (dict, words, wordcount, state);
if (ret) {
gf_log ("cli", GF_LOG_ERROR, "Failed to parse "
"restore command");
goto out;
}
break;
+
case GF_SNAP_OPTION_TYPE_ACTIVATE:
/* Syntax:
* snapshot activate <snapname> [force]
@@ -4250,6 +4266,7 @@ cli_cmd_snapshot_parse (const char **words, int wordcount, dict_t **options,
goto out;
}
break;
+
default:
gf_log ("", GF_LOG_ERROR, "Opword Mismatch");
goto out;