summaryrefslogtreecommitdiffstats
path: root/cli/src/cli-rpc-ops.c
diff options
context:
space:
mode:
authorKrutika Dhananjay <kdhananj@redhat.com>2013-09-04 16:07:08 +0530
committerKrutika Dhananjay <kdhananj@redhat.com>2013-09-06 14:57:09 +0530
commit08c555680d4aa0ec800ce617fdb119e83f9cd1f8 (patch)
tree9affb88545f8d95bef2ec29cea082b5f103c1f92 /cli/src/cli-rpc-ops.c
parentaa1da9c3207b9b1a1d91d09e5faf92510e7b61d7 (diff)
glusterd: add quota conf to probe payload
also fix FILE* leak in cli Original-author: Krishnan Parthasarathi <kparthas@redhat.com> Change-Id: Icb9b58ef065ce1a150d98b4c26bbcddeeb390e44 Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
Diffstat (limited to 'cli/src/cli-rpc-ops.c')
-rw-r--r--cli/src/cli-rpc-ops.c48
1 files changed, 40 insertions, 8 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 9c533af6..3edcd0d6 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -2457,8 +2457,8 @@ out:
return ret;
}
-static int
-print_quota_list_from_quotad (dict_t *rsp_dict)
+int
+print_quota_list_from_quotad (call_frame_t *frame, dict_t *rsp_dict)
{
int64_t used_space = 0;
int64_t avail = 0;
@@ -2469,7 +2469,13 @@ print_quota_list_from_quotad (dict_t *rsp_dict)
char *hl_str = NULL;
char *sl_final = NULL;
char *path = NULL;
+ char *default_sl = NULL;
int ret = -1;
+ cli_local_t *local = NULL;
+ dict_t *gd_rsp_dict = NULL;
+
+ local = frame->local;
+ gd_rsp_dict = local->dict;
struct quota_limit {
int64_t hl;
@@ -2489,6 +2495,13 @@ print_quota_list_from_quotad (dict_t *rsp_dict)
"limit key not present in dict");
goto out;
}
+
+ ret = dict_get_str (gd_rsp_dict, "default-soft-limit", &default_sl);
+ if (ret) {
+ gf_log (frame->this->name, GF_LOG_ERROR, "failed to "
+ "get default soft limit");
+ goto out;
+ }
existing_limits = (struct quota_limit *)limit;
existing_limits->hl = ntoh64 (existing_limits->hl);
existing_limits->sl = ntoh64 (existing_limits->sl);
@@ -2496,8 +2509,7 @@ print_quota_list_from_quotad (dict_t *rsp_dict)
hl_str = gf_uint64_2human_readable (existing_limits->hl);
if (existing_limits->sl == 0) {
- //TODO: need to fix this by fetching default sl from glusterd
- sl_final = "80%";
+ sl_final = default_sl;
} else {
snprintf (percent_str, sizeof (percent_str), "%"PRIu64"%%",
existing_limits->sl);
@@ -2582,7 +2594,7 @@ cli_quotad_getlimit_cbk (struct rpc_req *req, struct iovec *iov,
goto out;
}
}
- print_quota_list_from_quotad (dict);
+ print_quota_list_from_quotad (frame, dict);
out:
cli_cmd_broadcast_response (ret);
@@ -2658,12 +2670,17 @@ gf_cli_quota_cbk (struct rpc_req *req, struct iovec *iov,
call_frame_t *frame = NULL;
char *default_sl = NULL;
char *limit_list = NULL;
-
+ cli_local_t *local = NULL;
+ dict_t *aggr = NULL;
+ char *default_sl_dup = NULL;
+ int32_t entry_count = 0;
if (-1 == req->rpc_status) {
goto out;
}
frame = myframe;
+ local = frame->local;
+ aggr = local->dict;
ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp);
if (ret < 0) {
@@ -2708,12 +2725,27 @@ gf_cli_quota_cbk (struct rpc_req *req, struct iovec *iov,
gf_log (frame->this->name, GF_LOG_TRACE, "failed to get "
"default soft limit");
+ if (default_sl) {
+ default_sl_dup = gf_strdup (default_sl);
+ if (!default_sl_dup) {
+ ret = -1;
+ goto out;
+ }
+ ret = dict_set_dynstr (aggr, "default-soft-limit",
+ default_sl_dup);
+ if (ret) {
+ gf_log (frame->this->name, GF_LOG_TRACE,
+ "failed to set default soft limit");
+ GF_FREE (default_sl_dup);
+ }
+ }
+
ret = dict_get_int32 (dict, "type", &type);
if (ret)
gf_log (frame->this->name, GF_LOG_TRACE,
"failed to get type");
- ret = dict_get_int32 (dict, "count", &count);
+ ret = dict_get_int32 (dict, "count", &entry_count);
if (ret)
gf_log (frame->this->name, GF_LOG_TRACE, "failed to get count");
@@ -2728,7 +2760,7 @@ gf_cli_quota_cbk (struct rpc_req *req, struct iovec *iov,
goto out;
}
- gf_cli_quota_list (volname, dict, count, rsp.op_errstr,
+ gf_cli_quota_list (volname, dict, entry_count, rsp.op_errstr,
default_sl);
}