summaryrefslogtreecommitdiffstats
path: root/cli/src/cli-cmd-parser.c
diff options
context:
space:
mode:
authorAvra Sengupta <asengupt@redhat.com>2013-12-18 01:01:47 +0000
committerAvra Sengupta <asengupt@redhat.com>2014-01-07 15:26:25 +0530
commit4afa88d6cc39be11f122489900af07b57a50fcc4 (patch)
treed7a829bc7be6e98a2979ff35410ddccd674395bb /cli/src/cli-cmd-parser.c
parenta783136347ed2716f3f0ee0ca284f291f4e29652 (diff)
glusterd/snapshot: Defining snap-max-soft-limit as a percentage of snap-max-hard-limit.
This patch also prohibits configuration of snap-max-hard-limit and snap-max-soft-limit for snap volumes. Also displaying the snapshot configs by reading data only from local node, as all config data will be in sync across the cluster. Change-Id: I635b925c02ed5b108cd10c7193b154ad82d5afad BUG: 1043792 Signed-off-by: Avra Sengupta <asengupt@redhat.com>
Diffstat (limited to 'cli/src/cli-cmd-parser.c')
-rw-r--r--cli/src/cli-cmd-parser.c45
1 files changed, 25 insertions, 20 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index 2762f0cf4..59e951636 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -3203,8 +3203,11 @@ cli_snap_config_parse (const char **words, int wordcount, dict_t *options,
GF_ASSERT (options);
GF_ASSERT (state);
- if ((wordcount < 3) || (wordcount > 5))
+ if ((wordcount != 3) && (wordcount != 5)) {
+ gf_log ("", GF_LOG_ERROR,
+ "Invalid wordcount(%d)", wordcount);
goto out;
+ }
volname = (char *)words[2];
@@ -3226,11 +3229,19 @@ cli_snap_config_parse (const char **words, int wordcount, dict_t *options,
}
/* snapshot config <volname | all> [snap-max-hard-limit <count>
- * | snap-max-soft-limit <count>] */
+ * | snap-max-soft-limit <percent>] */
if (wordcount > 3) {
key = (char *) words[3];
value = (char *) words[4];
+ } else {
+ ret = dict_set_int32 (options, "config-command",
+ GF_SNAP_CONFIG_DISPLAY);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "Unable to set config-command");
+ ret = -1;
+ goto out;
+ }
}
if (key) {
@@ -3264,15 +3275,7 @@ cli_snap_config_parse (const char **words, int wordcount, dict_t *options,
}
}
- if (!value) {
- ret = dict_set_int32 (options, "config-command",
- GF_SNAP_CONFIG_DISPLAY);
- if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to set config-command");
- ret = -1;
- goto out;
- }
- } else {
+ if (value) {
ret = dict_set_int32 (options, "config-command",
GF_SNAP_CONFIG_TYPE_SET);
if (ret) {
@@ -3288,17 +3291,18 @@ cli_snap_config_parse (const char **words, int wordcount, dict_t *options,
"Failed to set %s.", key);
goto out;
}
- }
- /* Ask question only for a set op */
- if (value && conf_vals && conf_vals->question) {
- answer = cli_cmd_get_confirmation (state,
- conf_vals->question);
- if (GF_ANSWER_NO == answer) {
- ret = -1;
- goto out;
+ /* Ask question only for a set op */
+ if (conf_vals->question) {
+ answer = cli_cmd_get_confirmation (state,
+ conf_vals->question);
+ if (GF_ANSWER_NO == answer) {
+ ret = -1;
+ goto out;
+ }
}
}
+
out:
return ret;
}
@@ -3619,7 +3623,8 @@ cli_cmd_snapshot_parse (const char **words, int wordcount, dict_t **options,
}
case GF_SNAP_OPTION_TYPE_CONFIG:
{
- /* snapshot config <volname | all> [snap-max-hard-limit <count> | snap-max-soft-limit <count>] */
+ /* snapshot config <volname | all> [snap-max-hard-limit <count> |
+ * snap-max-soft-limit <percent>] */
ret = cli_snap_config_parse (words, wordcount, dict,
state);
if (ret) {