summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorAnuradha <atalur@redhat.com>2013-12-05 19:02:10 +0530
committerAnand Avati <avati@redhat.com>2014-02-08 11:40:21 -0800
commitdd9e406cf48142e7fa0619d17ccf3ecc71ce36ae (patch)
treee09665186abc10a9518f77daed8f8265390ae907 /cli
parent1e26f070bb470adafd0a316c18f2fb9e1b103f27 (diff)
quota : changes in quota list command
Changes are made to quota list command such that it also shows whether hard-limit and soft-limit are exceeded or not. A test case to check the same is added. Change-Id: Idb365acfc5d1f2d9f3373dd5f98573d5fe87b50f BUG: 1038598 Signed-off-by: Anuradha <atalur@redhat.com> Signed-off-by: Anuradha Talur <atalur@redhat.com> Reviewed-on: http://review.gluster.org/6441 Reviewed-by: Raghavendra G <rgowdapp@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-cmd-volume.c6
-rw-r--r--cli/src/cli-rpc-ops.c85
2 files changed, 63 insertions, 28 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index 9c29b7f..98e384f 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -1115,9 +1115,11 @@ print_quota_list_header (void)
{
//Header
cli_out (" Path Hard-limit "
- "Soft-limit Used Available");
+ "Soft-limit Used Available Soft-limit exceeded?"
+ " Hard-limit exceeded?");
cli_out ("-----------------------------------------------------"
- "---------------------------");
+ "-----------------------------------------------------"
+ "-----------------");
}
int
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 1da1cb9..bef7035 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -2318,8 +2318,11 @@ print_quota_list_output (char *mountdir, char *default_sl, char *path)
char *avail_str = NULL;
int ret = -1;
char *sl_final = NULL;
- char percent_str[20] = {0,};
char *hl_str = NULL;
+ double sl_num = 0;
+ gf_boolean_t sl = _gf_false;
+ gf_boolean_t hl = _gf_false;
+ char percent_str[20] = {0};
struct quota_limit {
int64_t hl;
@@ -2356,8 +2359,11 @@ print_quota_list_output (char *mountdir, char *default_sl, char *path)
hl_str = gf_uint64_2human_readable (existing_limits.hl);
if (existing_limits.sl < 0) {
+ ret = gf_string2percent (default_sl, &sl_num);
+ sl_num = (sl_num * existing_limits.hl) / 100;
sl_final = default_sl;
} else {
+ sl_num = (existing_limits.sl * existing_limits.hl) / 100;
snprintf (percent_str, sizeof (percent_str), "%"PRIu64"%%",
existing_limits.sl);
sl_final = percent_str;
@@ -2367,26 +2373,37 @@ print_quota_list_output (char *mountdir, char *default_sl, char *path)
&used_space, sizeof (used_space));
if (ret < 0) {
- cli_out ("%-40s %7s %9s %11s %7s", path, hl_str, sl_final,
- "N/A", "N/A");
+ cli_out ("%-40s %7s %9s %11s %7s %15s %20s",
+ path, hl_str, sl_final,
+ "N/A", "N/A", "N/A", "N/A");
} else {
used_space = ntoh64 (used_space);
used_str = gf_uint64_2human_readable (used_space);
- if (existing_limits.hl > used_space)
+ if (existing_limits.hl > used_space) {
avail = existing_limits.hl - used_space;
- else
+ hl = _gf_false;
+ if (used_space > sl_num)
+ sl = _gf_true;
+ else
+ sl = _gf_false;
+ } else {
avail = 0;
+ hl = sl = _gf_true;
+ }
avail_str = gf_uint64_2human_readable (avail);
- if (used_str == NULL)
+ if (used_str == NULL) {
cli_out ("%-40s %7s %9s %11"PRIu64
- "%9"PRIu64, path, hl_str,
- sl_final, used_space, avail);
- else
- cli_out ("%-40s %7s %9s %11s %7s", path, hl_str,
- sl_final, used_str, avail_str);
+ "%9"PRIu64" %15s %18s", path, hl_str,
+ sl_final, used_space, avail, sl? "Yes" : "No",
+ hl? "Yes" : "No");
+ } else {
+ cli_out ("%-40s %7s %9s %11s %7s %15s %20s", path, hl_str,
+ sl_final, used_str, avail_str, sl? "Yes" : "No",
+ hl? "Yes" : "No");
+ }
}
out:
@@ -2425,9 +2442,11 @@ gf_cli_print_limit_list_from_dict (char *volname, dict_t *dict,
}
cli_out (" Path Hard-limit "
- "Soft-limit Used Available");
- cli_out ("-----------------------------------------------------"
- "---------------------------");
+ "Soft-limit Used Available Soft-limit exceeded?"
+ " Hard-limit exceeded?");
+ cli_out ("--------------------------------------------------------"
+ "--------------------------------------------------------"
+ "-----------");
while (count--) {
snprintf (key, sizeof (key), "path%d", i++);
@@ -2458,14 +2477,17 @@ print_quota_list_from_quotad (call_frame_t *frame, dict_t *rsp_dict)
int64_t *limit = NULL;
char *used_str = NULL;
char *avail_str = NULL;
- char percent_str[20]= {0};
char *hl_str = NULL;
char *sl_final = NULL;
char *path = NULL;
- char *default_sl = NULL;
+ char *default_sl = NULL;
int ret = -1;
cli_local_t *local = NULL;
dict_t *gd_rsp_dict = NULL;
+ double sl_num = 0;
+ gf_boolean_t sl = _gf_false;
+ gf_boolean_t hl = _gf_false;
+ char percent_str[20] = {0,};
local = frame->local;
gd_rsp_dict = local->dict;
@@ -2502,37 +2524,48 @@ print_quota_list_from_quotad (call_frame_t *frame, dict_t *rsp_dict)
hl_str = gf_uint64_2human_readable (existing_limits->hl);
if (existing_limits->sl < 0) {
+ ret = gf_string2percent (default_sl, &sl_num);
+ sl_num = (sl_num * existing_limits->hl) / 100;
sl_final = default_sl;
} else {
+ sl_num = (existing_limits->sl * existing_limits->hl) / 100;
snprintf (percent_str, sizeof (percent_str), "%"PRIu64"%%",
existing_limits->sl);
- sl_final = percent_str;
+ sl_final = percent_str;
}
ret = dict_get_bin (rsp_dict, QUOTA_SIZE_KEY, (void**)&limit);
if (ret < 0) {
gf_log ("cli", GF_LOG_WARNING,
"size key not present in dict");
- cli_out ("%-40s %7s %9s %11s %7s", path, hl_str, sl_final,
- "N/A", "N/A");
+ cli_out ("%-40s %7s %9s %11s %7s %15s %20s", path, hl_str,
+ sl_final, "N/A", "N/A", "N/A", "N/A");
} else {
used_space = *limit;
used_space = ntoh64 (used_space);
used_str = gf_uint64_2human_readable (used_space);
- if (existing_limits->hl > used_space)
+ if (existing_limits->hl > used_space) {
avail = existing_limits->hl - used_space;
- else
+ hl = _gf_false;
+ if (used_space > sl_num)
+ sl = _gf_true;
+ else
+ sl = _gf_false;
+ } else {
avail = 0;
-
+ hl = sl = _gf_true;
+ }
avail_str = gf_uint64_2human_readable (avail);
if (used_str == NULL)
cli_out ("%-40s %7s %9s %11"PRIu64
- "%9"PRIu64, path, hl_str,
- sl_final, used_space, avail);
+ "%9"PRIu64" %15s %20s", path, hl_str,
+ sl_final, used_space, avail, sl? "Yes" : "No",
+ hl? "Yes" : "No");
else
- cli_out ("%-40s %7s %9s %11s %7s", path, hl_str,
- sl_final, used_str, avail_str);
+ cli_out ("%-40s %7s %9s %11s %7s %15s %20s", path,
+ hl_str, sl_final, used_str, avail_str,
+ sl? "Yes" : "No", hl? "Yes" : "No");
}
ret = 0;