From 437d51f42813299435c297e9c0a1312dcaf0a6f4 Mon Sep 17 00:00:00 2001 From: "Bala.FA" Date: Thu, 26 Sep 2013 08:09:35 +0530 Subject: cli: add node uuid in rebalance and remove brick status xml output This patch adds node uuid in rebalance/remove-brick status xml output. Output XML will look like 0 0 3 1 localhost ==>> 883626f8-4d29-4d02-8c5d-c9f48c5b2445 0 0 0 0 3 completed 0 0 0 0 3 completed Change-Id: Ie2eb6e8d024605326d1a710b7c40ee30139f0f22 BUG: 1012296 Signed-off-by: Bala.FA Reviewed-on: http://review.gluster.org/6032 Reviewed-by: Kaushal M Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- cli/src/cli-rpc-ops.c | 20 ++++++++++---------- cli/src/cli-xml-output.c | 12 +++++++++++- xlators/mgmt/glusterd/src/glusterd-op-sm.c | 23 ++++++++++++++++++++++- 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 81692ffa532..6e22316d1da 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -1235,7 +1235,7 @@ gf_cli_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov, char msg[1024] = {0,}; gf_defrag_status_t status_rcd = GF_DEFRAG_STATUS_NOT_STARTED; int32_t counter = 0; - char *node_uuid = NULL; + char *node_name = NULL; char key[256] = {0,}; int32_t i = 1; uint64_t failures = 0; @@ -1362,11 +1362,11 @@ gf_cli_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov, "-----------", "-----------", "-----------", "-----------", "-----------", "------------", "--------------"); do { - snprintf (key, 256, "node-uuid-%d", i); - ret = dict_get_str (dict, key, &node_uuid); + snprintf (key, 256, "node-name-%d", i); + ret = dict_get_str (dict, key, &node_name); if (ret) gf_log (THIS->name, GF_LOG_TRACE, - "failed to get node-uuid"); + "failed to get node-name"); memset (key, 0, 256); snprintf (key, 256, "files-%d", i); @@ -1419,7 +1419,7 @@ gf_cli_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov, 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 - " %13"PRIu64 " %14s %16.2f", node_uuid, files, + " %13"PRIu64 " %14s %16.2f", node_name, files, size_str, lookup, failures, skipped, status, elapsed); GF_FREE(size_str); @@ -1729,7 +1729,7 @@ gf_cli3_remove_brick_status_cbk (struct rpc_req *req, struct iovec *iov, char key[256] = {0,}; int32_t i = 1; int32_t counter = 0; - char *node_uuid = 0; + char *node_name = 0; gf_defrag_status_t status_rcd = GF_DEFRAG_STATUS_NOT_STARTED; uint64_t failures = 0; uint64_t skipped = 0; @@ -1815,11 +1815,11 @@ xml_output: "-----------","------------", "--------------"); do { - snprintf (key, 256, "node-uuid-%d", i); - ret = dict_get_str (dict, key, &node_uuid); + snprintf (key, 256, "node-name-%d", i); + ret = dict_get_str (dict, key, &node_name); if (ret) gf_log (THIS->name, GF_LOG_TRACE, - "failed to get node-uuid"); + "failed to get node-name"); memset (key, 0, 256); snprintf (key, 256, "files-%d", i); @@ -1887,7 +1887,7 @@ xml_output: 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, + " %14s %16.2f", node_name, files, size_str, lookup, failures, status, elapsed); GF_FREE(size_str); diff --git a/cli/src/cli-xml-output.c b/cli/src/cli-xml-output.c index b9f4cfe46db..21ca1ae7fb7 100644 --- a/cli/src/cli-xml-output.c +++ b/cli/src/cli-xml-output.c @@ -2977,6 +2977,7 @@ cli_xml_output_vol_rebalance_status (xmlTextWriterPtr writer, dict_t *dict, int ret = -1; int count = 0; char *node_name = NULL; + char *node_uuid = NULL; uint64_t files = 0; uint64_t size = 0; uint64_t lookups = 0; @@ -3014,13 +3015,22 @@ cli_xml_output_vol_rebalance_status (xmlTextWriterPtr writer, dict_t *dict, XML_RET_CHECK_AND_GOTO (ret, out); memset (key, 0, sizeof (key)); - snprintf (key, sizeof (key), "node-uuid-%d", i); + snprintf (key, sizeof (key), "node-name-%d", i); ret = dict_get_str (dict, key, &node_name); if (ret) goto out; ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"nodeName", "%s", node_name); + + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "node-uuid-%d", i); + ret = dict_get_str (dict, key, &node_uuid); + if (ret) + goto out; + ret = xmlTextWriterWriteFormatElement (writer, + (xmlChar *)"id", + "%s", node_uuid); XML_RET_CHECK_AND_GOTO (ret, out); memset (key, 0, sizeof (key)); diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index 18054dcc93c..7c7dcda618e 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -3148,8 +3148,29 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx) goto out; } + /* add 'node-name-%d' into op_ctx with value uuid_str. + this will be used to convert to hostname later */ + { + char key[1024]; + char *uuid_str = NULL; + int i; + + for (i = 1; i <= count; i++) { + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "node-uuid-%d", i); + ret = dict_get_str (op_ctx, key, &uuid_str); + if (!ret) { + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), + "node-name-%d", i); + ret = dict_set_str (op_ctx, key, + uuid_str); + } + } + } + ret = glusterd_op_volume_dict_uuid_to_hostname (op_ctx, - "node-uuid-%d", + "node-name-%d", 1, (count + 1)); if (ret) gf_log (this->name, GF_LOG_WARNING, -- cgit