summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cli/src/cli-cmd-parser.c82
-rw-r--r--cli/src/cli-cmd-snapshot.c2
-rwxr-xr-xtests/basic/volume-snapshot.t4
-rw-r--r--tests/bugs/bug-1040934.t2
-rw-r--r--tests/bugs/bug-1045333.t6
-rwxr-xr-xtests/bugs/bug-1049834.t2
-rwxr-xr-xtests/snapshot.rc4
7 files changed, 70 insertions, 32 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index 6b8f2929f..f14fc702c 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -3409,6 +3409,52 @@ out:
return ret;
}
+/* snapshot delete <snapname>
+ * @arg-0, dict : Request Dictionary to be sent to server side.
+ * @arg-1, words : Contains individual words of CLI command.
+ * @arg-2, wordcount: Contains number of words present in the CLI command.
+ * @arg-3, cmdi : command index, here cmdi is "2" (gluster snapshot delete)
+ *
+ * return value : -1 on failure
+ * 0 on success
+ */
+int
+cli_snap_delete_parse (dict_t *dict, const char **words, int wordcount,
+ unsigned int cmdi, struct cli_state *state) {
+
+ int ret = -1;
+ const char *question = NULL;
+ gf_answer_t answer = GF_ANSWER_NO;
+
+ question = "Deleting snap will erase all the information about "
+ "the snap. Do you still want to continue?";
+
+ GF_ASSERT (words);
+ GF_ASSERT (dict);
+
+ if (wordcount != 3) {
+ gf_log ("cli", GF_LOG_ERROR, "Invalid Syntax");
+ goto out;
+ }
+
+ ret = dict_set_str (dict, "snap-name", (char *)words[cmdi]);
+ if (ret) {
+ gf_log ("cli", GF_LOG_ERROR, "Unable to save snap-name %s",
+ words[cmdi]);
+ goto out;
+ }
+
+ answer = cli_cmd_get_confirmation (state, question);
+ if (GF_ANSWER_NO == answer) {
+ ret = -1;
+ gf_log ("cli", GF_LOG_DEBUG, "User cancelled "
+ "snapshot delete operation");
+ goto out;
+ }
+out :
+ return ret;
+}
+
int32_t
cli_cmd_snapshot_parse (const char **words, int wordcount, dict_t **options,
@@ -3518,29 +3564,21 @@ cli_cmd_snapshot_parse (const char **words, int wordcount, dict_t **options,
break;
}
- case GF_SNAP_OPTION_TYPE_DELETE:
- {
- /*syntax:
- snapshot remove [<volname> -s <snap-name> | -c <cg-name>]
- */
- w = str_getunamb (words[2], opwords);
- if (w) {
- gf_log ("", GF_LOG_ERROR, "Opword Mismatch");
- goto out;
- }
-
- cmdi = 2;
+ case GF_SNAP_OPTION_TYPE_DELETE:
+ {
+ /* Syntax :
+ * gluster snapshot delete <snap-name>
+ */
+ ret = cli_snap_delete_parse (dict, words, wordcount,
+ cmdi, state);
+ if (ret) {
+ gf_log ("cli", GF_LOG_ERROR, "Failed to parse "
+ "snapshot delete command");
+ goto out;
+ }
+ break;
+ }
- ret = cli_snap_remove_parse (dict, words,
- wordcount, cmdi, state);
- if (ret) {
- if (ret < 0)
- gf_log ("", GF_LOG_ERROR,
- "remove command parsing failed.");
- goto out;
- }
- break;
- }
case GF_SNAP_OPTION_TYPE_CONFIG:
{
/* snapshot config <volname | all> [snap-max-hard-limit <count> |
diff --git a/cli/src/cli-cmd-snapshot.c b/cli/src/cli-cmd-snapshot.c
index 4d824a007..93e154eab 100644
--- a/cli/src/cli-cmd-snapshot.c
+++ b/cli/src/cli-cmd-snapshot.c
@@ -103,7 +103,7 @@ struct cli_cmd snapshot_cmds[] = {
cli_cmd_snapshot_cbk,
"Snapshot Config."
},
- {"snapshot delete (<volname> -s <snapname> | -c <cgname>) [force]",
+ {"snapshot delete <snap-name>",
cli_cmd_snapshot_cbk,
"Snapshot Delete."
},
diff --git a/tests/basic/volume-snapshot.t b/tests/basic/volume-snapshot.t
index f6b88068e..4bc0792db 100755
--- a/tests/basic/volume-snapshot.t
+++ b/tests/basic/volume-snapshot.t
@@ -28,10 +28,10 @@ function create_snapshots() {
}
function delete_snapshots() {
- $CLI_1 snapshot delete $V0 -s ${V0}_snap &
+ $CLI_1 snapshot delete ${V0}_snap &
PID_1=$!
- $CLI_1 snapshot delete $V1 -s ${V1}_snap &
+ $CLI_1 snapshot delete ${V1}_snap &
PID_2=$!
wait $PID_1 $PID_2
diff --git a/tests/bugs/bug-1040934.t b/tests/bugs/bug-1040934.t
index 547f6c3bc..d057f0cb7 100644
--- a/tests/bugs/bug-1040934.t
+++ b/tests/bugs/bug-1040934.t
@@ -28,7 +28,7 @@ TEST mount -t glusterfs $H1:/snaps/${V0}_snap/$V0 $M0
cd $M0
TEST ! touch a
-TEST $CLI_1 snapshot delete $V0 -s ${V0}_snap
+TEST $CLI_1 snapshot delete ${V0}_snap
PID_1=$!
wait $PID_1
diff --git a/tests/bugs/bug-1045333.t b/tests/bugs/bug-1045333.t
index c1fd71beb..59ef1c5e7 100644
--- a/tests/bugs/bug-1045333.t
+++ b/tests/bugs/bug-1045333.t
@@ -38,9 +38,9 @@ TEST mount -t glusterfs $H0:/snaps/$S3/$V0 $M0
TEST umount -f $M0
#Clean up
-TEST $CLI snapshot delete $V0 -s $S1
-TEST $CLI snapshot delete $V0 -s $S2
-TEST $CLI snapshot delete $V0 -s $S3
+TEST $CLI snapshot delete $S1
+TEST $CLI snapshot delete $S2
+TEST $CLI snapshot delete $S3
TEST $CLI volume stop $V0 force
TEST $CLI volume delete $V0
diff --git a/tests/bugs/bug-1049834.t b/tests/bugs/bug-1049834.t
index ea4b3c85d..6587fb765 100755
--- a/tests/bugs/bug-1049834.t
+++ b/tests/bugs/bug-1049834.t
@@ -31,7 +31,7 @@ TEST snapshot_n_exists $V0 4 $V0_snap
#Creating the 5th snapshots on the volume and expecting it not to be created.
TEST ! $CLI_1 snapshot create $V0 -n ${V0}_snap5
TEST ! snapshot_exists ${V0}_snap5
-TEST ! $CLI_1 snapshot delete $V0 -s ${V0}_snap5
+TEST ! $CLI_1 snapshot delete ${V0}_snap5
#Deleting the 4 snaps
TEST delete_n_snapshots $V0 4 $V0_snap
diff --git a/tests/snapshot.rc b/tests/snapshot.rc
index 230f62a68..52481b0fb 100755
--- a/tests/snapshot.rc
+++ b/tests/snapshot.rc
@@ -172,7 +172,7 @@ function _remove_vhd() {
########################################################
function snapshot_exists() {
local snapname=$1
- $CLI snapshot list | egrep -q "\s$snapname\b"
+ $CLI snapshot list | egrep -q "^$snapname\$"
return $?
}
@@ -214,7 +214,7 @@ function delete_n_snapshots() {
local snap_name=$3
local ret=0
for i in `seq 1 $snap_count`; do
- $CLI_1 snapshot delete ${vol} -s $snap_name$i &
+ $CLI_1 snapshot delete $snap_name$i &
PID_1=$!
wait $PID_1
temp=$?