diff options
| author | vmallika <vmallika@redhat.com> | 2014-10-28 12:25:43 +0530 | 
|---|---|---|
| committer | Kaushal M <kaushal@redhat.com> | 2014-11-12 04:36:11 -0800 | 
| commit | 4fa4b7f2c2b57d1055adb76e8258b0db176bc356 (patch) | |
| tree | e4beb4567c57370b8622f19746721e2a0b0f96f1 /cli/src/cli-cmd-parser.c | |
| parent | 55aa4b185561edd7b3d1ab77a4f29a4facfdd7ff (diff) | |
glusterd/snapshot: Snapshot should be deactivated when it is created
By default snapshot should be deactivated and this should be a
configurable option.
This behaviour can be configured by the command below:
gluster snapshot config activate-on-create <enable|disable>
Change-Id: I1911595c32beed43bb2fca4bf99f0d264b422513
BUG: 1157991
Signed-off-by: vmallika <vmallika@redhat.com>
Reviewed-on: http://review.gluster.org/8985
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Avra Sengupta <asengupt@redhat.com>
Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
Reviewed-by: Kaushal M <kaushal@redhat.com>
Diffstat (limited to 'cli/src/cli-cmd-parser.c')
| -rw-r--r-- | cli/src/cli-cmd-parser.c | 51 | 
1 files changed, 41 insertions, 10 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 27f1fec0df8..28888ba656d 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -278,7 +278,7 @@ cli_cmd_volume_create_parse (struct cli_state *state, const char **words,                                         "description", "force",                                         "snap-max-hard-limit",                                         "snap-max-soft-limit", "auto-delete", -                                       NULL}; +                                       "activate-on-create", NULL};          char    *w = NULL;          char    *ptr = NULL;          int      op_count = 0; @@ -3868,8 +3868,7 @@ cli_snap_config_parse (const char **words, int wordcount, dict_t *dict,          int8_t                         soft_limit          = 0;          int8_t                         config_type         = -1;          const char                    *question            = NULL; -        unsigned int                    cmdi               = 2; -        int8_t                         auto_delete         = -1; +        unsigned int                   cmdi                = 2;          /* cmdi is command index, here cmdi is "2" (gluster snapshot config)*/          GF_ASSERT (words); @@ -3892,7 +3891,8 @@ cli_snap_config_parse (const char **words, int wordcount, dict_t *dict,          /* Check whether the 3rd word is volname */          if (strcmp (words[cmdi], "snap-max-hard-limit") != 0               && strcmp (words[cmdi], "snap-max-soft-limit") != 0 -             && strcmp (words[cmdi], "auto-delete") != 0) { +             && strcmp (words[cmdi], "auto-delete") != 0 +             && strcmp (words[cmdi], "activate-on-create") != 0) {                  ret = dict_set_str (dict, "volname", (char *)words[cmdi]);                  if (ret) {                          gf_log ("cli", GF_LOG_ERROR, "Failed to set volname"); @@ -3950,10 +3950,12 @@ cli_snap_config_parse (const char **words, int wordcount, dict_t *dict,                          goto out;                  }                  soft_limit = 1; -                goto set;          } -        if (hard_limit != 1 && (strcmp(words[cmdi], "auto-delete") == 0)) { +        if (hard_limit || soft_limit) +                goto set; + +        if (strcmp(words[cmdi], "auto-delete") == 0) {                  if (vol_presence == 1) {                          ret = -1;                          cli_err ("As of now, auto-delete option cannot be set " @@ -3976,19 +3978,47 @@ cli_snap_config_parse (const char **words, int wordcount, dict_t *dict,                                  "dictionary");                          goto out;                  } -                auto_delete = 1;                  if (++cmdi != wordcount) {                          ret = -1;                          gf_log ("cli", GF_LOG_ERROR, "Invalid Syntax");                          goto out;                  } -        } -        else { +        } else if (strcmp(words[cmdi], "activate-on-create") == 0) { +                if (vol_presence == 1) { +                        ret = -1; +                        cli_err ("As of now, activate-on-create option " +                                 "cannot be set to volumes"); +                        gf_log ("cli", GF_LOG_ERROR, "activate-on-create " +                                "option cannot be set to volumes"); +                        goto out; +                } + +                if (++cmdi >= wordcount) { +                        ret = -1; +                        gf_log ("cli", GF_LOG_ERROR, "Invalid Syntax"); +                        goto out; +                } + +                ret = dict_set_str (dict, "snap-activate-on-create", +                                    (char *)words[cmdi]); +                if (ret) { +                        gf_log ("cli", GF_LOG_ERROR, "Failed to set value " +                                "of activate-on-create in request dictionary"); +                        goto out; +                } + +                if (++cmdi != wordcount) { +                        ret = -1; +                        gf_log ("cli", GF_LOG_ERROR, "Invalid Syntax"); +                        goto out; +                } +        } else {                  ret = -1;                  gf_log ("cli", GF_LOG_ERROR, "Invalid Syntax");                  goto out;          } +          ret = 0; /* Success */  set: @@ -3999,7 +4029,8 @@ set:                  goto out;          } -        if (config_type == GF_SNAP_CONFIG_TYPE_SET && auto_delete != 1) { +        if (config_type == GF_SNAP_CONFIG_TYPE_SET && +           (hard_limit || soft_limit)) {                  conf_vals = snap_confopt_vals;                  if (hard_limit && soft_limit) {                          question = conf_vals[GF_SNAP_CONFIG_SET_BOTH].question;  | 
