summaryrefslogtreecommitdiffstats
path: root/cli/src
diff options
context:
space:
mode:
authorSachin Pandit <spandit@redhat.com>2014-02-20 14:00:22 +0530
committerRajesh Joseph <rjoseph@redhat.com>2014-03-05 02:13:25 -0800
commitfabee8f75c56f18c949b79dcc751c2855b5c7514 (patch)
treedb78a64c7b49c6727a15171d8b894aa4e1992aab /cli/src
parentae62c3aec7b92dc5325a04add9ab0ac63ff05fa5 (diff)
cli/snapshot : snapshot delete CLI changes.
Syntax: gluster snapshot delete <snapname> Change-Id: I5de7b9a79eeba12e4f0b8abfbe96a2db738f25c0 Signed-off-by: Sachin Pandit <spandit@redhat.com> Reviewed-on: http://review.gluster.org/7144 Reviewed-by: Rajesh Joseph <rjoseph@redhat.com> Tested-by: Rajesh Joseph <rjoseph@redhat.com>
Diffstat (limited to 'cli/src')
-rw-r--r--cli/src/cli-cmd-parser.c82
-rw-r--r--cli/src/cli-cmd-snapshot.c2
2 files changed, 61 insertions, 23 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index 6b8f292..f14fc70 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 4d824a0..93e154e 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."
},