diff options
author | Avra Sengupta <asengupt@redhat.com> | 2013-12-16 03:09:58 +0000 |
---|---|---|
committer | Rajesh Joseph <rjoseph@redhat.com> | 2014-01-06 15:59:43 +0530 |
commit | 5d57885a1b63ba89406c0dbd02bb254eacf531bd (patch) | |
tree | 81675d15f4d450ac80c2b67cf1e4b2e68a5405b2 /cli/src/cli-rpc-ops.c | |
parent | 31ed53e48a2066ba344c257856384ad105803281 (diff) |
glusterd/snapshot: Introducing snap-max-hard-limit and snap-max-soft-limit
Note: Manually adding this patch again as this patch got missed in
git reset option done on remote development branch
Change-Id: I9e81c5ec003c1e1722d0fcb27dd87c365ee43ff4
Signed-off-by: Avra Sengupta <asengupt@redhat.com>
Signed-off-by: Rajesh Joseph <rjoseph@redhat.com>
Diffstat (limited to 'cli/src/cli-rpc-ops.c')
-rw-r--r-- | cli/src/cli-rpc-ops.c | 147 |
1 files changed, 103 insertions, 44 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 31fd616ff..926c01b70 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -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: |