diff options
Diffstat (limited to 'cli/src/cli-rpc-ops.c')
-rw-r--r-- | cli/src/cli-rpc-ops.c | 151 |
1 files changed, 105 insertions, 46 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 1a90e192c..926c01b70 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -7671,7 +7671,7 @@ list_snap_of_volume (dict_t *dict_n, char *prefix_str) { continue; } ret = snprintf (buffer, sizeof(buffer), - "%s.snap-%ld.cgname", prefix_str, i); + "%s.snap-%ld.cg-name", prefix_str, i); if (ret < 0) { /* Negative value is an error */ goto out; } @@ -7744,7 +7744,7 @@ list_snap_of_cg (dict_t *dict) { goto out; } - ret = dict_get_str (dict, "snaplist.cg-0.cgname", &get_buffer); + ret = dict_get_str (dict, "snaplist.cg-0.cg-name", &get_buffer); if (ret) { /* if cg_name is not present then exit, it is not necessary * to check other details if cg_name is not present @@ -7896,6 +7896,106 @@ out: } int +cli_snapshot_config_display (dict_t *dict, gf_cli_rsp *rsp) +{ + char *volname = NULL; + char *key = NULL; + int ret = -1; + int config_command = 0; + uint64_t value = 0; + + GF_ASSERT (dict); + GF_ASSERT (rsp); + + if (rsp->op_ret) { + cli_err ("Snapshot Config : failed: %s", + rsp->op_errstr ? rsp->op_errstr : + "Please check log file for details"); + ret = rsp->op_ret; + goto out; + } + + ret = dict_get_int32 (dict, "config-command", &config_command); + if (ret) { + gf_log("", GF_LOG_DEBUG, "Could not fetch config type"); + ret = -1; + goto out; + } + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { + gf_log("", GF_LOG_ERROR, "Could not fetch " + "volname"); + ret = -1; + goto out; + } + + if (!strcmp (volname, "all")) { + volname = "System"; + } + + ret = dict_get_str (dict, "config-key", &key); + if (ret) + gf_log("", GF_LOG_ERROR, "No config-key set"); + + switch (config_command) { + case GF_SNAP_CONFIG_TYPE_SET: + cli_out ("snapshot config: %s " + "for %s set successfully", key, volname); + break; + + case GF_SNAP_CONFIG_DISPLAY : + if (!key) { + /* For all options */ + ret = dict_get_uint64 (dict, "snap-max-hard-limit", + &value); + if (ret) { + gf_log("", GF_LOG_DEBUG, "Could not fetch " + "snap_max_hard_limit for %s", volname); + ret = -1; + goto out; + } + cli_out ("snapshot config: snap-max-hard-limit for " + "%s set to %"PRIu64, + volname, value); + + ret = dict_get_uint64 (dict, "snap-max-soft-limit", + &value); + if (ret) { + gf_log("", GF_LOG_DEBUG, "Could not fetch " + "snap-max-soft-limit for %s", volname); + 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); + } + } + break; + default : + break; + } + + ret = 0; +out: + return ret; +} + +int gf_cli_snapshot_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { @@ -7907,9 +8007,6 @@ gf_cli_snapshot_cbk (struct rpc_req *req, struct iovec *iov, int32_t type = 0; int64_t volcount = -1; call_frame_t *frame = NULL; - uint64_t limit = 0; - int32_t config_command = 0; - char *volname = NULL; if (req->rpc_status == -1) { ret = -1; @@ -8056,50 +8153,12 @@ gf_cli_snapshot_cbk (struct rpc_req *req, struct iovec *iov, break; case GF_SNAP_OPTION_TYPE_CONFIG: - if (rsp.op_ret) { - cli_err ("Snapshot Config : failed: %s", - rsp.op_errstr ? rsp.op_errstr : - "Please check log file for details"); - ret = rsp.op_ret; - goto out; - } - - ret = dict_get_int32 (dict, "config-command", &config_command); - + ret = cli_snapshot_config_display (dict, &rsp); if (ret) { - gf_log("", GF_LOG_DEBUG, "Could not fetch config type"); - ret = -1; - goto out; - } - - ret = dict_get_str (dict, "volname", &volname); - if (ret) { - gf_log("", GF_LOG_DEBUG, "Could not fetch " - "volname"); - ret = -1; + gf_log ("", GF_LOG_ERROR, "Failed to display snapshot " + "config output."); goto out; } - - if (!strcmp (volname, "all")) { - volname = "System"; - } - - if (config_command == GF_SNAP_CONFIG_DISPLAY) { - - ret = dict_get_uint64 (dict, "limit", &limit); - if (ret) { - gf_log("", GF_LOG_DEBUG, "Could not fetch " - "limit for %s", volname); - ret = -1; - goto out; - } - cli_out ("snapshot config: snap-max-limit for " - "%s set to %"PRIu64, - volname, limit); - } else { - cli_out ("snapshot config: snap-max-limit " - "for %s set successfully", volname); - } break; case GF_SNAP_OPTION_TYPE_DELETE: |