From c8e970495d24af1303b4dda8da9ac7bd6c8849fe Mon Sep 17 00:00:00 2001 From: Kaushal M Date: Fri, 30 Aug 2013 14:37:03 +0530 Subject: cli: Add statusStr xml tag to task list and rebalance/remove brick status Backport of cd7951aa31ae4bbdf35fc6d1f2466636844b889d from master New xml tag statusStr added to following gluster cli commands gluster volume status all --xml (For Task status) gluster volume rebalance status --xml gluster volume remove-brick status --xml Example(volume status all): Rebalance 82d8d122-8738-4144-8507-d93fc98b61df 3 completed Example(volume rebalance status) localhost 0 0 0 0 3 completed Also modified task status as string instead of showing number in gluster volume status all Example: Status of volume: gv1 Gluster process Port Online Pid ------------------------------------------------------------------------------ Brick sumne.sumne:/gfs/b1 49154 Y 15489 Brick sumne.sumne:/gfs/b2 49155 Y 15493 NFS Server on localhost N/A N 15913 Task ID Status ---- -- ------ Rebalance 82d8d122-8738-4144-8507-d93fc98b61df completed BUG: 1003521 Change-Id: I2f6845b621cbd5a74aeb3a3195f944536745e0ec Original-author: Aravinda VK Signed-off-by: Kaushal M Reviewed-on: http://review.gluster.org/5969 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- cli/src/cli-rpc-ops.c | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) (limited to 'cli/src/cli-rpc-ops.c') diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 5a13ff165..4cb867442 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -66,6 +66,13 @@ char *cli_volume_backend[] = {"", "Volume Group", }; +char *cli_vol_task_status_str[] = {"not started", + "in progress", + "stopped", + "completed", + "failed", +}; + int32_t gf_cli_get_volume (call_frame_t *frame, xlator_t *this, void *data); @@ -1401,24 +1408,7 @@ gf_cli_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov, gf_log (THIS->name, GF_LOG_TRACE, "failed to get run-time"); - switch (status_rcd) { - case GF_DEFRAG_STATUS_NOT_STARTED: - status = "not started"; - break; - case GF_DEFRAG_STATUS_STARTED: - status = "in progress"; - break; - case GF_DEFRAG_STATUS_STOPPED: - status = "stopped"; - break; - case GF_DEFRAG_STATUS_COMPLETE: - status = "completed"; - break; - case GF_DEFRAG_STATUS_FAILED: - status = "failed"; - break; - } - + status = cli_vol_task_status_str[status_rcd]; size_str = gf_uint64_2human_readable(size); cli_out ("%40s %16"PRIu64 " %13s" " %13"PRIu64 " %13"PRIu64 " %14s %16.2f", node_uuid, files, size_str, lookup, @@ -5613,7 +5603,20 @@ cli_print_volume_tasks (dict_t *dict) { if (ret) return; - cli_out ("%15s%40s%15d", op, task_id_str, status); + /* + Replace brick only has two states - In progress and Complete + Ref: xlators/mgmt/glusterd/src/glusterd-replace-brick.c + */ + if (!strcmp (op, "Replace brick")) { + if (status) { + status = GF_DEFRAG_STATUS_COMPLETE; + } else { + status = GF_DEFRAG_STATUS_STARTED; + } + } + + cli_out ("%15s%40s%15s", op, task_id_str, + cli_vol_task_status_str[status]); } } -- cgit