summaryrefslogtreecommitdiffstats
path: root/cli/src
diff options
context:
space:
mode:
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 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."
},