diff options
Diffstat (limited to 'cli/src/cli-rpc-ops.c')
-rw-r--r-- | cli/src/cli-rpc-ops.c | 104 |
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; |