summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-cmd-parser.c45
-rw-r--r--cli/src/cli-cmd-snapshot.c2
-rw-r--r--cli/src/cli-rpc-ops.c108
3 files changed, 95 insertions, 60 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index 3b1a8a92d..1059ea90e 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -3197,8 +3197,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];
@@ -3220,11 +3223,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) {
@@ -3258,15 +3269,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) {
@@ -3282,17 +3285,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;
}
@@ -3613,7 +3617,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) {
diff --git a/cli/src/cli-cmd-snapshot.c b/cli/src/cli-cmd-snapshot.c
index 556278931..6d31dc2d5 100644
--- a/cli/src/cli-cmd-snapshot.c
+++ b/cli/src/cli-cmd-snapshot.c
@@ -90,7 +90,7 @@ struct cli_cmd snapshot_cmds[] = {
cli_cmd_snapshot_cbk,
"Snapshot List."
},
- {"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> ]",
cli_cmd_snapshot_cbk,
"Snapshot Config."
},
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 926c01b70..90fb8e4b9 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -7898,11 +7898,15 @@ out:
int
cli_snapshot_config_display (dict_t *dict, gf_cli_rsp *rsp)
{
+ char buf[PATH_MAX] = "";
char *volname = NULL;
char *key = NULL;
int ret = -1;
int config_command = 0;
uint64_t value = 0;
+ uint64_t soft_limit = 0;
+ uint64_t i = 0;
+ uint64_t voldisplaycount = 0;
GF_ASSERT (dict);
GF_ASSERT (rsp);
@@ -7917,8 +7921,7 @@ cli_snapshot_config_display (dict_t *dict, gf_cli_rsp *rsp)
ret = dict_get_int32 (dict, "config-command", &config_command);
if (ret) {
- gf_log("", GF_LOG_DEBUG, "Could not fetch config type");
- ret = -1;
+ gf_log("", GF_LOG_ERROR, "Could not fetch config type");
goto out;
}
@@ -7926,7 +7929,6 @@ cli_snapshot_config_display (dict_t *dict, gf_cli_rsp *rsp)
if (ret) {
gf_log("", GF_LOG_ERROR, "Could not fetch "
"volname");
- ret = -1;
goto out;
}
@@ -7935,8 +7937,11 @@ cli_snapshot_config_display (dict_t *dict, gf_cli_rsp *rsp)
}
ret = dict_get_str (dict, "config-key", &key);
- if (ret)
- gf_log("", GF_LOG_ERROR, "No config-key set");
+ if (ret && config_command != GF_SNAP_CONFIG_DISPLAY) {
+ gf_log(THIS->name, GF_LOG_ERROR,
+ "Could not fetch config-key");
+ goto out;
+ }
switch (config_command) {
case GF_SNAP_CONFIG_TYPE_SET:
@@ -7945,49 +7950,74 @@ cli_snapshot_config_display (dict_t *dict, gf_cli_rsp *rsp)
break;
case GF_SNAP_CONFIG_DISPLAY :
- if (!key) {
- /* For all options */
- ret = dict_get_uint64 (dict, "snap-max-hard-limit",
- &value);
+ cli_out ("\nSnapshot System Configuration:");
+ ret = dict_get_uint64 (dict, "snap-max-hard-limit",
+ &value);
+ if (ret) {
+ gf_log("", GF_LOG_ERROR, "Could not fetch "
+ "snap_max_hard_limit for %s", volname);
+ ret = -1;
+ goto out;
+ }
+ cli_out ("snap-max-hard-limit : %"PRIu64, value);
+
+ ret = dict_get_uint64 (dict, "snap-max-soft-limit",
+ &soft_limit);
+ if (ret) {
+ gf_log("", GF_LOG_ERROR, "Could not fetch "
+ "snap-max-soft-limit for %s", volname);
+ ret = -1;
+ goto out;
+ }
+ cli_out ("snap-max-soft-limit : %"PRIu64"%%\n", soft_limit);
+
+ cli_out ("Snapshot Volume Configuration:");
+
+ ret = dict_get_uint64 (dict, "voldisplaycount",
+ &voldisplaycount);
+ if (ret) {
+ gf_log("", GF_LOG_ERROR, "Could not fetch voldisplaycount");
+ ret = -1;
+ goto out;
+ }
+
+ for (i = 0; i < voldisplaycount; i++) {
+ snprintf (buf, sizeof(buf), "volume%ld-volname", i);
+ ret = dict_get_str (dict, buf, &volname);
if (ret) {
- gf_log("", GF_LOG_DEBUG, "Could not fetch "
- "snap_max_hard_limit for %s", volname);
+ gf_log("", GF_LOG_ERROR, "Could not fetch "
+ " %s", buf);
ret = -1;
goto out;
}
- cli_out ("snapshot config: snap-max-hard-limit for "
- "%s set to %"PRIu64,
- volname, value);
+ cli_out ("\nVolume : %s", volname);
- ret = dict_get_uint64 (dict, "snap-max-soft-limit",
- &value);
+ snprintf (buf, sizeof(buf),
+ "volume%ld-snap-max-hard-limit", i);
+ ret = dict_get_uint64 (dict, buf, &value);
if (ret) {
- gf_log("", GF_LOG_DEBUG, "Could not fetch "
- "snap-max-soft-limit for %s", volname);
+ gf_log("", GF_LOG_ERROR, "Could not fetch "
+ " %s", buf);
ret = -1;
goto out;
}
- cli_out ("snapshot config: snap-max-soft-limit for "
- "%s set to %"PRIu64,
- volname, value);
- } else {
- if ((!strncmp (key, "snap-max-hard-limit", strlen(key))) ||
- (!strncmp (key, "snap-max-soft-limit", strlen(key)))) {
- ret = dict_get_uint64 (dict, key, &value);
- if (ret) {
- gf_log("", GF_LOG_DEBUG, "Could not fetch "
- "%s for %s", key, volname);
- ret = -1;
- goto out;
- }
- cli_out ("snapshot config: %s for "
- "%s set to %"PRIu64, key,
- volname, value);
+ cli_out ("snap-max-hard-limit : %"PRIu64, value);
+
+ snprintf (buf, sizeof(buf),
+ "volume%ld-snap-max-soft-limit-value", i);
+ ret = dict_get_uint64 (dict, buf, &value);
+ if (ret) {
+ gf_log("", GF_LOG_ERROR, "Could not fetch "
+ " %s", buf);
+ ret = -1;
+ goto out;
}
- }
- break;
+ cli_out ("snap-max-soft-limit : %"PRIu64" (%"PRIu64"%%)",
+ value, soft_limit);
+ }
+ break;
default :
- break;
+ break;
}
ret = 0;
@@ -8087,9 +8117,9 @@ gf_cli_snapshot_cbk (struct rpc_req *req, struct iovec *iov,
goto out;
}
- ret = dict_get_str (dict, "cg-name", &cg_name);
+ ret = dict_get_str (dict, "cgname", &cg_name);
if (ret) {
- ret = dict_get_str (dict, "snap-name", &snap_name);
+ ret = dict_get_str (dict, "snapname", &snap_name);
if (ret) {
gf_log (frame->this->name, GF_LOG_ERROR,
"Failed to get CG name or snap name");