summaryrefslogtreecommitdiffstats
path: root/cli/src/cli-rpc-ops.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-rpc-ops.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-rpc-ops.c')
-rw-r--r--cli/src/cli-rpc-ops.c104
1 files changed, 67 insertions, 37 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 926c01b70..6ee039fbc 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;