diff options
| author | Sachin Pandit <spandit@redhat.com> | 2014-08-25 05:42:38 +0530 | 
|---|---|---|
| committer | Vijay Bellur <vbellur@redhat.com> | 2014-09-23 03:14:39 -0700 | 
| commit | 40dcfefb73e3e00e7cbd22a44c3bd795612f356a (patch) | |
| tree | 1e30c1f90fddf748368e4c207d8af26e8317fb28 | |
| parent | cd60de7b2fd8d40be83ee75773e703e6327c47db (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: 1145092
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>
Signed-off-by: Sachin Pandit <spandit@redhat.com>
Reviewed-on: http://review.gluster.org/8806
| -rw-r--r-- | cli/src/cli-cmd-parser.c | 21 | 
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;  | 
