From 67b7752eccd8eae6a91f3bc3ff55d65dcf858dc7 Mon Sep 17 00:00:00 2001 From: Ravishankar N Date: Mon, 18 Jan 2016 12:19:35 +0530 Subject: cli: Add arbiter details to volinfo xml output The following are added: 1. "1" and "1" 2. "0" on the brick info, like so: 127.0.0.2:/home/ravi/bricks/brick1 127.0.0.2:/home/ravi/bricks/brick1 cafa8612-d7d4-4007-beea-72ae7477f3bb 0 Also fix a bug in gluster vol info where the abiter brick was shown the wrong brick of the cold tier after performing a tier-attach. Change-Id: Id978325d02b04f1a08856427827320e169169810 BUG: 1297750 Signed-off-by: Ravishankar N Reviewed-on: http://review.gluster.org/13229 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Pranith Kumar Karampuri --- cli/src/cli-xml-output.c | 50 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) (limited to 'cli/src/cli-xml-output.c') diff --git a/cli/src/cli-xml-output.c b/cli/src/cli-xml-output.c index 7140f803071..f7ae0578b15 100644 --- a/cli/src/cli-xml-output.c +++ b/cli/src/cli-xml-output.c @@ -2551,6 +2551,8 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) int dist_count = 0; int stripe_count = 0; int replica_count = 0; + int arbiter_count = 0; + int isArbiter = 0; int disperse_count = 0; int redundancy_count = 0; int transport = 0; @@ -2561,6 +2563,7 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) char *caps = NULL; int k __attribute__((unused)) = 0; int index = 1; + int start_index = 1; int vol_type = -1; int tier_vol_type = 0; /*hot disperse count, redundancy count and dist count are always @@ -2569,17 +2572,18 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) int hot_dist_count = 0; int hot_redundancy_count = 0; values c = 0; - char *keys[30] = { + char *keys[MAX] = { [COLD_BRICK_COUNT] = "volume%d.cold_brick_count", [COLD_TYPE] = "volume%d.cold_type", [COLD_DIST_COUNT] = "volume%d.cold_dist_count", [COLD_REPLICA_COUNT] = "volume%d.cold_replica_count", + [COLD_ARBITER_COUNT] = "volume%d.cold_arbiter_count", [COLD_DISPERSE_COUNT] = "volume%d.cold_disperse_count", [COLD_REDUNDANCY_COUNT] = "volume%d.cold_redundancy_count", [HOT_BRICK_COUNT] = "volume%d.hot_brick_count", [HOT_TYPE] = "volume%d.hot_type", [HOT_REPLICA_COUNT] = "volume%d.hot_replica_count"}; - int value[9] = {}; + int value[MAX] = {}; ret = dict_get_int32 (dict, "count", &count); @@ -2667,6 +2671,16 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) "%d", replica_count); XML_RET_CHECK_AND_GOTO (ret, out); + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "volume%d.arbiter_count", i); + ret = dict_get_int32 (dict, key, &arbiter_count); + if (ret) + goto out; + ret = xmlTextWriterWriteFormatElement (local->writer, + (xmlChar *)"arbiterCount", + "%d", arbiter_count); + XML_RET_CHECK_AND_GOTO (ret, out); + memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.disperse_count", i); ret = dict_get_int32 (dict, key, &disperse_count); @@ -2909,6 +2923,11 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) "%d", value[COLD_REPLICA_COUNT]); XML_RET_CHECK_AND_GOTO (ret, out); + ret = xmlTextWriterWriteFormatElement (local->writer, + (xmlChar *)"coldarbiterCount", + "%d", value[COLD_ARBITER_COUNT]); + XML_RET_CHECK_AND_GOTO (ret, out); + ret = xmlTextWriterWriteFormatElement (local->writer, (xmlChar *)"coldbrickCount", "%d", @@ -2952,7 +2971,7 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) value[COLD_BRICK_COUNT]); } - index = value[HOT_BRICK_COUNT] + 1; + start_index = index = value[HOT_BRICK_COUNT] + 1; while (index <= brick_count) { snprintf (key, 1024, "volume%d.brick%d", i, @@ -2990,6 +3009,19 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) "%s", uuid); XML_RET_CHECK_AND_GOTO (ret, out); + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), + "volume%d.brick%d.isArbiter", i, + index); + if (dict_get (dict, key)) + isArbiter = 1; + else + isArbiter = 0; + ret = xmlTextWriterWriteFormatElement + (local->writer, (xmlChar *)"isArbiter", + "%d", isArbiter); + XML_RET_CHECK_AND_GOTO (ret, out); + ret = xmlTextWriterEndElement (local->writer); XML_RET_CHECK_AND_GOTO (ret, out); @@ -3035,6 +3067,18 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) "%s", uuid); XML_RET_CHECK_AND_GOTO (ret, out); + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), + "volume%d.brick%d.isArbiter", i, j); + if (dict_get (dict, key)) + isArbiter = 1; + else + isArbiter = 0; + ret = xmlTextWriterWriteFormatElement + (local->writer, (xmlChar *)"isArbiter", + "%d", isArbiter); + XML_RET_CHECK_AND_GOTO (ret, out); + /* */ ret = xmlTextWriterEndElement (local->writer); XML_RET_CHECK_AND_GOTO (ret, out); -- cgit