diff options
author | Joseph Fernandes <josferna@redhat.com> | 2014-04-21 20:28:22 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2014-04-30 23:27:23 -0700 |
commit | f63fbca7540a4c9ce090e1ed5941ed8777ff6316 (patch) | |
tree | f342c9aa37cbbc45ebfa66f77daff25696eac569 /cli | |
parent | 57fddef768d0e0feee07e5d745dcb4656fe5cb84 (diff) |
[glusterd/snapshot] snapshot create force option
Implement force option in snapshot create i.e
1) Creation of snapshot fails if the original volume
bricks are down
2) With a force option creation of snapshot will continue
even if the original volume bricks are down.
This was the fix for bugs 1089527 and 1083502
Change-Id: I8de0242adf8ee0af00db9fa8701d86fabc12e7fc
BUG: 1090042
Signed-off-by: Joseph Fernandes <josferna@redhat.com>
Reviewed-on: http://review.gluster.org/7520
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'cli')
-rw-r--r-- | cli/src/cli-cmd-parser.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 5fdb9d08a74..de0654a744b 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -2986,12 +2986,13 @@ out: */ int cli_snap_create_parse (dict_t *dict, const char **words, int wordcount) { - uint64_t i = 0; + uint64_t i = 0; int ret = -1; - uint64_t volcount = 0; - char key[PATH_MAX] = ""; + uint64_t volcount = 0; + char key[PATH_MAX] = ""; char *snapname = NULL; - unsigned int cmdi = 2; + unsigned int cmdi = 2; + int flags = 0; /* cmdi is command index, here cmdi is "2" (gluster snapshot create)*/ GF_ASSERT (words); @@ -3107,18 +3108,15 @@ cli_snap_create_parse (dict_t *dict, const char **words, int wordcount) { */ } - if ((strcmp (words[i], "force") != 0)) { + if (strcmp (words[i], "force") == 0) { + flags = GF_CLI_FLAG_OP_FORCE; + + } else { ret = -1; cli_err ("Invalid Syntax."); gf_log ("cli", GF_LOG_ERROR, "Invalid Syntax"); goto out; } - ret = dict_set_int8 (dict, "snap-force", 1); - if (ret) { - gf_log ("cli", GF_LOG_ERROR, "Could not save " - "snap force option"); - goto out; - } /* Check if the command has anything after "force" keyword */ if (++i < wordcount) { @@ -3130,6 +3128,15 @@ cli_snap_create_parse (dict_t *dict, const char **words, int wordcount) { ret = 0; out: + if(ret == 0) { + /*Adding force flag in either of the case i.e force set + * or unset*/ + ret = dict_set_int32 (dict, "flags", flags); + if (ret) { + gf_log ("cli", GF_LOG_ERROR, "Could not save " + "snap force option"); + } + } return ret; } |