diff options
Diffstat (limited to 'cli/src/cli-rpc-ops.c')
-rw-r--r-- | cli/src/cli-rpc-ops.c | 71 |
1 files changed, 49 insertions, 22 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 677431127..6e0f24d5f 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -7569,10 +7569,10 @@ 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 hard_limit = 0; uint64_t soft_limit = 0; uint64_t i = 0; uint64_t voldisplaycount = 0; @@ -7590,23 +7590,24 @@ 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_ERROR, "Could not fetch config type"); + gf_log ("cli", GF_LOG_ERROR, "Could not fetch config type"); goto out; } ret = dict_get_str (dict, "volname", &volname); - if (ret) { - gf_log("", GF_LOG_ERROR, "Could not fetch " - "volname"); - goto out; - } + /* Ignore the error, as volname is optional */ - if (!strcmp (volname, "all")) { + if (!volname) { volname = "System"; } - ret = dict_get_str (dict, "config-key", &key); - if (ret && config_command != GF_SNAP_CONFIG_DISPLAY) { + ret = dict_get_uint64 (dict, "snap-max-hard-limit", &hard_limit); + /* Ignore the error, as the key specified is optional */ + ret = dict_get_uint64 (dict, "snap-max-soft-limit", &soft_limit); + + if (!hard_limit && !soft_limit + && config_command != GF_SNAP_CONFIG_DISPLAY) { + ret = -1; gf_log(THIS->name, GF_LOG_ERROR, "Could not fetch config-key"); goto out; @@ -7614,8 +7615,19 @@ cli_snapshot_config_display (dict_t *dict, gf_cli_rsp *rsp) switch (config_command) { case GF_SNAP_CONFIG_TYPE_SET: - cli_out ("snapshot config: %s " - "for %s set successfully", key, volname); + if (hard_limit && soft_limit) { + cli_out ("snapshot config: snap-max-hard-limit " + "& snap-max-soft-limit for system set " + "successfully"); + } else if (hard_limit){ + cli_out ("snapshot config: %s " + "for snap-max-hard-limit set successfully", + volname); + } else if (soft_limit) { + cli_out ("snapshot config: %s " + "for snap-max-soft-limit set successfully", + volname); + } break; case GF_SNAP_CONFIG_DISPLAY : @@ -7623,7 +7635,7 @@ cli_snapshot_config_display (dict_t *dict, gf_cli_rsp *rsp) ret = dict_get_uint64 (dict, "snap-max-hard-limit", &value); if (ret) { - gf_log("", GF_LOG_ERROR, "Could not fetch " + gf_log ("cli", GF_LOG_ERROR, "Could not fetch " "snap_max_hard_limit for %s", volname); ret = -1; goto out; @@ -7633,19 +7645,21 @@ cli_snapshot_config_display (dict_t *dict, gf_cli_rsp *rsp) ret = dict_get_uint64 (dict, "snap-max-soft-limit", &soft_limit); if (ret) { - gf_log("", GF_LOG_ERROR, "Could not fetch " + gf_log ("cli", 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 ("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"); + gf_log ("cli", GF_LOG_ERROR, + "Could not fetch voldisplaycount"); ret = -1; goto out; } @@ -7654,7 +7668,7 @@ cli_snapshot_config_display (dict_t *dict, gf_cli_rsp *rsp) snprintf (buf, sizeof(buf), "volume%ld-volname", i); ret = dict_get_str (dict, buf, &volname); if (ret) { - gf_log("", GF_LOG_ERROR, "Could not fetch " + gf_log ("cli", GF_LOG_ERROR, "Could not fetch " " %s", buf); ret = -1; goto out; @@ -7665,7 +7679,7 @@ cli_snapshot_config_display (dict_t *dict, gf_cli_rsp *rsp) "volume%ld-snap-max-hard-limit", i); ret = dict_get_uint64 (dict, buf, &value); if (ret) { - gf_log("", GF_LOG_ERROR, "Could not fetch " + gf_log ("cli", GF_LOG_ERROR, "Could not fetch " " %s", buf); ret = -1; goto out; @@ -7673,16 +7687,29 @@ cli_snapshot_config_display (dict_t *dict, gf_cli_rsp *rsp) cli_out ("snap-max-hard-limit : %"PRIu64, value); snprintf (buf, sizeof(buf), - "volume%ld-snap-max-soft-limit-value", i); + "volume%ld-active-hard-limit", i); ret = dict_get_uint64 (dict, buf, &value); if (ret) { - gf_log("", GF_LOG_ERROR, "Could not fetch " + gf_log ("cli", GF_LOG_ERROR, "Could not fetch" + " effective snap_max_hard_limit for " + "%s", volname); + ret = -1; + goto out; + } + cli_out ("Effective snap-max-hard-limit : %"PRIu64, + value); + + snprintf (buf, sizeof(buf), + "volume%ld-snap-max-soft-limit", i); + ret = dict_get_uint64 (dict, buf, &value); + if (ret) { + gf_log ("cli", GF_LOG_ERROR, "Could not fetch " " %s", buf); ret = -1; goto out; } - cli_out ("snap-max-soft-limit : %"PRIu64" (%"PRIu64"%%)", - value, soft_limit); + cli_out ("Effective snap-max-soft-limit : %"PRIu64" " + "(%"PRIu64"%%)", value, soft_limit); } break; default : |