summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorManikandan Selvaganesh <mselvaga@redhat.com>2015-09-09 13:03:37 +0530
committerKaushal M <kaushal@redhat.com>2015-10-05 00:15:50 -0700
commitdf06d94fae1e4a5e93f00c26d4b377bd8d1bd352 (patch)
treea44a6497da7d4d55550b851d6e6ebc5e67415224 /cli
parente4c5188cdfe407d9ccdecd56c65d4771f098ffa8 (diff)
quota : xml output modified to give exact available space in bytes
Currrently, 'gluster v quota <VOLNAME> list' command rounds off the available space and shows it to the user. Now, 'gluster v quota <VOLNAME> list --xml' command is modified to show the exact available space in bytes. Backport of http://review.gluster.org/#/c/12137/ > Change-Id: I3772e036a2537c1df12f22cf32dfe4ac7940988f > BUG: 1261404 > Signed-off-by: Manikandan Selvaganesh <mselvaga@redhat.com> Change-Id: I3772e036a2537c1df12f22cf32dfe4ac7940988f BUG: 1267817 Signed-off-by: Manikandan Selvaganesh <mselvaga@redhat.com> Reviewed-on: http://review.gluster.org/12267 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Kaushal M <kaushal@redhat.com>
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-rpc-ops.c10
-rw-r--r--cli/src/cli-xml-output.c51
-rw-r--r--cli/src/cli.h11
3 files changed, 36 insertions, 36 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 4991d3a92ba..b9fdb5933a4 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -2940,9 +2940,9 @@ print_quota_list_usage_output (cli_local_t *local, char *path, int64_t avail,
sl_val = gf_uint64_2human_readable (sl_num);
if (global_state->mode & GLUSTER_MODE_XML) {
- ret = cli_quota_xml_output (local, path, hl_str,
- sl_str, used_str,
- avail_str, sl ? "Yes" : "No",
+ ret = cli_quota_xml_output (local, path, limits->hl,
+ sl_str, sl_num, used_space->size,
+ avail, sl ? "Yes" : "No",
hl ? "Yes" : "No");
if (ret) {
gf_log ("cli", GF_LOG_ERROR, "Failed to "
@@ -2981,8 +2981,8 @@ print_quota_list_object_output (cli_local_t *local, char *path, int64_t avail,
int64_t sl_val = sl_num;
if (global_state->mode & GLUSTER_MODE_XML) {
- ret = cli_quota_object_xml_output (local, path, sl_str, limits,
- used_space, avail,
+ ret = cli_quota_object_xml_output (local, path, sl_str, sl_val,
+ limits, used_space, avail,
sl ? "Yes" : "No",
hl ? "Yes" : "No");
if (ret) {
diff --git a/cli/src/cli-xml-output.c b/cli/src/cli-xml-output.c
index 6167adbc73c..753966d7736 100644
--- a/cli/src/cli-xml-output.c
+++ b/cli/src/cli-xml-output.c
@@ -6184,9 +6184,9 @@ out:
}
int
-cli_quota_xml_output (cli_local_t *local, char *path, char *hl_str,
- char *sl_final, void *used, void *avail, char *sl,
- char *hl)
+cli_quota_xml_output (cli_local_t *local, char *path, int64_t hl_str,
+ char *sl_final, int64_t sl_num, int64_t used,
+ int64_t avail, char *sl, char *hl)
{
#if (HAVE_LIB_XML)
int ret = -1;
@@ -6201,34 +6201,27 @@ cli_quota_xml_output (cli_local_t *local, char *path, char *hl_str,
ret = xmlTextWriterWriteFormatElement (local->writer,
(xmlChar *)"hard_limit",
- "%s", hl_str);
+ "%"PRIu64, hl_str);
XML_RET_CHECK_AND_GOTO (ret, out);
ret = xmlTextWriterWriteFormatElement (local->writer,
- (xmlChar *)"soft_limit",
+ (xmlChar *)"soft_limit_percent",
"%s", sl_final);
XML_RET_CHECK_AND_GOTO (ret, out);
- if ((char *)used) {
- ret = xmlTextWriterWriteFormatElement
- (local->writer, (xmlChar *)"used_space", "%s",
- (char *)used);
- } else {
- ret = xmlTextWriterWriteFormatElement
- (local->writer, (xmlChar *)"user_space", "%11"PRIu64,
- *(long unsigned int *)used);
- }
+ ret = xmlTextWriterWriteFormatElement (local->writer,
+ (xmlChar *)"soft_limit_value",
+ "%"PRIu64, sl_num);
XML_RET_CHECK_AND_GOTO (ret, out);
- if ((char *)avail) {
- ret = xmlTextWriterWriteFormatElement
- (local->writer, (xmlChar *)"avail_space", "%s",
- (char *)avail);
- } else {
- ret = xmlTextWriterWriteFormatElement
- (local->writer, (xmlChar *)"avail_space", "%11"PRIu64,
- *(long unsigned int *)avail);
- }
+ ret = xmlTextWriterWriteFormatElement (local->writer,
+ (xmlChar *)"used_space",
+ "%"PRIu64, used);
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
+ ret = xmlTextWriterWriteFormatElement (local->writer,
+ (xmlChar *)"avail_space",
+ "%"PRIu64, avail);
XML_RET_CHECK_AND_GOTO (ret, out);
ret = xmlTextWriterWriteFormatElement (local->writer,
@@ -6254,8 +6247,9 @@ out:
int
cli_quota_object_xml_output (cli_local_t *local, char *path, char *sl_str,
- quota_limits_t *limits, quota_meta_t *used_space,
- int64_t avail, char *sl, char *hl)
+ int64_t sl_val, quota_limits_t *limits,
+ quota_meta_t *used_space, int64_t avail,
+ char *sl, char *hl)
{
#if (HAVE_LIB_XML)
int ret = -1;
@@ -6274,11 +6268,16 @@ cli_quota_object_xml_output (cli_local_t *local, char *path, char *sl_str,
XML_RET_CHECK_AND_GOTO (ret, out);
ret = xmlTextWriterWriteFormatElement (local->writer,
- (xmlChar *)"soft_limit",
+ (xmlChar *)"soft_limit_percent",
"%s", sl_str);
XML_RET_CHECK_AND_GOTO (ret, out);
ret = xmlTextWriterWriteFormatElement (local->writer,
+ (xmlChar *)"soft_limit_value",
+ "%"PRIu64, sl_val);
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
+ ret = xmlTextWriterWriteFormatElement (local->writer,
(xmlChar *)"file_count",
"%"PRIu64,
used_space->file_count);
diff --git a/cli/src/cli.h b/cli/src/cli.h
index 926d7014927..ccf55761870 100644
--- a/cli/src/cli.h
+++ b/cli/src/cli.h
@@ -403,14 +403,15 @@ cli_quota_list_xml_error (cli_local_t *local, char *path,
char *errstr);
int
-cli_quota_xml_output (cli_local_t *local, char *path, char *hl_str,
- char *sl_final, void *used, void *avail,
- char *sl, char *hl);
+cli_quota_xml_output (cli_local_t *local, char *path, int64_t hl_str,
+ char *sl_final, int64_t sl_num, int64_t used,
+ int64_t avail, char *sl, char *hl);
int
cli_quota_object_xml_output (cli_local_t *local, char *path, char *sl_str,
- quota_limits_t *limits, quota_meta_t *used_space,
- int64_t avail, char *sl, char *hl);
+ int64_t sl_val, quota_limits_t *limits,
+ quota_meta_t *used_space, int64_t avail,
+ char *sl, char *hl);
int
cli_xml_output_peer_status (dict_t *dict, int op_ret, int op_errno,