summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorhari gowtham <hgowtham@redhat.com>2015-09-10 20:15:35 +0530
committerDan Lambright <dlambrig@redhat.com>2015-09-29 06:10:09 -0700
commitccea4c9d575c4cf46ac93575a1c62be90af5372b (patch)
tree4c3f59a44cbacf03f0fff2f4b728d3039ffd4897 /cli
parent5be6f0339b5ad189868a50b837ae7b8c164a5b25 (diff)
Tier/cli: tier related information in volume info xml
gluster v info didnt differentiate the hot bricks and cold bricks and other few values <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <cliOutput> <opRet>0</opRet> <opErrno>0</opErrno> <opErrstr/> <volInfo> <volumes> <volume> <name>rmbr</name> <id>72d223fc-96ba-4f4a-ac6e-0d0bc16ef127</id> <status>1</status> <statusStr>Started</statusStr> <brickCount>3</brickCount> <distCount>1</distCount> <stripeCount>1</stripeCount> <replicaCount>1</replicaCount> <disperseCount>0</disperseCount> <redundancyCount>0</redundancyCount> <type>5</type> <typeStr>Tier</typeStr> <transport>0</transport> <xlators/> <bricks> <hotBricks> <hotBrickType>Distribute</hotBrickType> <numberOfBricks>1</numberOfBricks> <brick uuid="81">v1:/hb1<name>v1:/hb1</name><hostUuid>81</hostUuid></brick> </hotBricks> <coldBricks> <coldBrickType>Distribute</coldBrickType> <numberOfBricks>2</numberOfBricks> <brick uuid="81">v1:/br1<name>v1:/br1</name><hostUuid>81</hostUuid></brick> <brick uuid="81">v1:/br2<name>v1:/br2</name><hostUuid>81</hostUuid></brick> <count>0</count> </coldBricks> </bricks> </volume> </volumes> </volInfo> </cliOutput> Change-Id: I6e52541bb6d8a6a17e17bfcb42434beaac13db56 BUG: 1261837 Signed-off-by: hari gowtham <hgowtham@redhat.com> Reviewed-on: http://review.gluster.org/12158 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Dan Lambright <dlambrig@redhat.com> Tested-by: Dan Lambright <dlambrig@redhat.com>
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-xml-output.c281
-rw-r--r--cli/src/cli.h13
2 files changed, 266 insertions, 28 deletions
diff --git a/cli/src/cli-xml-output.c b/cli/src/cli-xml-output.c
index 3ad7250397b..6167adbc73c 100644
--- a/cli/src/cli-xml-output.c
+++ b/cli/src/cli-xml-output.c
@@ -2559,6 +2559,27 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict)
int j = 1;
char *caps = NULL;
int k __attribute__((unused)) = 0;
+ int index = 1;
+ int vol_type = -1;
+ int tier_vol_type = 0;
+ /*hot disperse count, redundancy count and dist count are always
+ * zero so need for them to be included in the array.*/
+ int hot_disperse_count = 0;
+ int hot_dist_count = 0;
+ int hot_redundancy_count = 0;
+ values c = 0;
+ char *keys[30] = {
+ [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_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] = {};
+
ret = dict_get_int32 (dict, "count", &count);
if (ret)
@@ -2758,46 +2779,250 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict)
ret = xmlTextWriterStartElement (local->writer,
(xmlChar *)"bricks");
XML_RET_CHECK_AND_GOTO (ret, out);
- while (j <= brick_count) {
- ret = xmlTextWriterStartElement
- (local->writer, (xmlChar *)"brick");
- XML_RET_CHECK_AND_GOTO (ret, out);
- memset (key, 0, sizeof (key));
- snprintf (key, sizeof (key), "volume%d.brick%d.uuid",
- i, j);
- ret = dict_get_str (dict, key, &uuid);
- if (ret)
- goto out;
- ret = xmlTextWriterWriteFormatAttribute
- (local->writer, (xmlChar *)"uuid", "%s",
- uuid);
- XML_RET_CHECK_AND_GOTO (ret, out);
+ if (type == GF_CLUSTER_TYPE_TIER) {
+ /*the values for hot stripe, disperse and redundancy
+ * should not be looped in here as they are zero
+ * always */
+ for (c = COLD_BRICK_COUNT; c < MAX; c++) {
- memset (key, 0, sizeof (key));
- snprintf (key, sizeof (key), "volume%d.brick%d", i, j);
- ret = dict_get_str (dict, key, &brick);
- if (ret)
- goto out;
- ret = xmlTextWriterWriteFormatString
- (local->writer, "%s", brick);
+ memset (key, 0, sizeof (key));
+ snprintf (key, 256, keys[c], i);
+ ret = dict_get_int32 (dict, key, &value[c]);
+ if (ret)
+ goto out;
+ }
+
+ tier_vol_type = value[HOT_TYPE];
+ value[hot_dist_count] = (value[HOT_REPLICA_COUNT] ?
+ value[HOT_REPLICA_COUNT] : 1);
+ if ((value[HOT_TYPE] != GF_CLUSTER_TYPE_TIER) &&
+ (value[HOT_TYPE] > 0) &&
+ (value[hot_dist_count] < value[HOT_BRICK_COUNT]))
+ tier_vol_type = value[HOT_TYPE] +
+ GF_CLUSTER_TYPE_MAX - 1;
+
+ ret = xmlTextWriterStartElement (local->writer,
+ (xmlChar *)
+ "hotBricks");
XML_RET_CHECK_AND_GOTO (ret, out);
ret = xmlTextWriterWriteFormatElement
- (local->writer, (xmlChar *)"name", "%s",
- brick);
+ (local->writer, (xmlChar *)"hotBrickType",
+ "%s", cli_vol_type_str[tier_vol_type]);
+
+ if (value[HOT_TYPE] == GF_CLUSTER_TYPE_NONE ||
+ value[HOT_TYPE] ==
+ GF_CLUSTER_TYPE_TIER) {
+ ret = xmlTextWriterWriteFormatElement
+ (local->writer,
+ (xmlChar *)"numberOfBricks",
+ "%d", value[HOT_BRICK_COUNT]);
+ XML_RET_CHECK_AND_GOTO (ret, out);
+ } else if (value[HOT_TYPE] ==
+ GF_CLUSTER_TYPE_DISPERSE) {
+ ret = xmlTextWriterWriteFormatElement
+ (local->writer,
+ (xmlChar *)"numberOfBricks",
+ "%d x (%d + %d) = %d",
+ (value[HOT_BRICK_COUNT] /
+ value[hot_dist_count]),
+ hot_disperse_count -
+ hot_redundancy_count,
+ hot_redundancy_count,
+ value[HOT_BRICK_COUNT]);
+ } else {
+ ret = xmlTextWriterWriteFormatElement
+ (local->writer,
+ (xmlChar *)"numberOfBricks",
+ "%d x %d = %d",
+ (value[HOT_BRICK_COUNT] /
+ value[hot_dist_count]),
+ value[hot_dist_count],
+ value[HOT_BRICK_COUNT]);
+ }
+
+ while (index <= value[HOT_BRICK_COUNT]) {
+ snprintf (key, 1024, "volume%d.brick%d", i,
+ index);
+ ret = dict_get_str (dict, key, &brick);
+ if (ret)
+ goto out;
+
+ ret = xmlTextWriterStartElement
+ (local->writer, (xmlChar *)"brick");
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
+ memset (key, 0, sizeof (key));
+ snprintf (key, sizeof (key),
+ "volume%d.brick%d.uuid", i, j);
+ ret = dict_get_str (dict, key, &uuid);
+ if (ret)
+ goto out;
+ ret = xmlTextWriterWriteFormatAttribute
+ (local->writer, (xmlChar *)"uuid", "%s",
+ uuid);
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
+ ret = xmlTextWriterWriteFormatString
+ (local->writer, "%s", brick);
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
+ ret = xmlTextWriterWriteFormatElement
+ (local->writer, (xmlChar *)"name", "%s",
+ brick);
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
+ ret = xmlTextWriterWriteFormatElement
+ (local->writer, (xmlChar *)"hostUuid",
+ "%s", uuid);
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
+ ret = xmlTextWriterEndElement (local->writer);
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
+ index++;
+ }
+ ret = xmlTextWriterEndElement (local->writer);
XML_RET_CHECK_AND_GOTO (ret, out);
- ret = xmlTextWriterWriteFormatElement
- (local->writer, (xmlChar *)"hostUuid", "%s",
- uuid);
+ tier_vol_type = value[COLD_TYPE];
+ if ((value[COLD_TYPE] != GF_CLUSTER_TYPE_TIER) &&
+ (value[COLD_TYPE] > 0) &&
+ (value[COLD_DIST_COUNT] < value[COLD_BRICK_COUNT]))
+ tier_vol_type = value[COLD_TYPE] +
+ GF_CLUSTER_TYPE_MAX - 1;
+
+
+ ret = xmlTextWriterStartElement (local->writer,
+ (xmlChar *)
+ "coldBricks");
XML_RET_CHECK_AND_GOTO (ret, out);
- /* </brick> */
+ ret = xmlTextWriterWriteFormatElement
+ (local->writer, (xmlChar *)"coldBrickType",
+ "%s", cli_vol_type_str[tier_vol_type]);
+
+ if (value[COLD_TYPE] == GF_CLUSTER_TYPE_NONE ||
+ value[COLD_TYPE] ==
+ GF_CLUSTER_TYPE_TIER) {
+ ret = xmlTextWriterWriteFormatElement
+ (local->writer,
+ (xmlChar *)"numberOfBricks",
+ "%d", value[COLD_BRICK_COUNT]);
+ XML_RET_CHECK_AND_GOTO (ret, out);
+ } else if (value[COLD_TYPE] ==
+ GF_CLUSTER_TYPE_DISPERSE) {
+ ret = xmlTextWriterWriteFormatElement
+ (local->writer,
+ (xmlChar *)"numberOfBricks",
+ " %d x (%d + %d) = %d",
+ (value[COLD_BRICK_COUNT] /
+ value[COLD_DIST_COUNT]),
+ value[COLD_DISPERSE_COUNT] -
+ value[COLD_REDUNDANCY_COUNT],
+ value[COLD_REDUNDANCY_COUNT],
+ value[COLD_BRICK_COUNT]);
+ } else {
+ ret = xmlTextWriterWriteFormatElement
+ (local->writer,
+ (xmlChar *)"numberOfBricks",
+ "%d x %d = %d",
+ (value[COLD_BRICK_COUNT] /
+ value[COLD_DIST_COUNT]),
+ value[COLD_DIST_COUNT],
+ value[COLD_BRICK_COUNT]);
+ }
+
+ index = value[HOT_BRICK_COUNT] + 1;
+
+ while (index <= brick_count) {
+ snprintf (key, 1024, "volume%d.brick%d", i,
+ index);
+ ret = dict_get_str (dict, key, &brick);
+ if (ret)
+ goto out;
+
+ ret = xmlTextWriterStartElement
+ (local->writer, (xmlChar *)"brick");
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
+ memset (key, 0, sizeof (key));
+ snprintf (key, sizeof (key),
+ "volume%d.brick%d.uuid", i, j);
+ ret = dict_get_str (dict, key, &uuid);
+ if (ret)
+ goto out;
+ ret = xmlTextWriterWriteFormatAttribute
+ (local->writer, (xmlChar *)"uuid", "%s",
+ uuid);
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
+ ret = xmlTextWriterWriteFormatString
+ (local->writer, "%s", brick);
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
+ ret = xmlTextWriterWriteFormatElement
+ (local->writer, (xmlChar *)"name", "%s",
+ brick);
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
+ ret = xmlTextWriterWriteFormatElement
+ (local->writer, (xmlChar *)"hostUuid",
+ "%s", uuid);
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
+ ret = xmlTextWriterEndElement (local->writer);
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
+ index++;
+ }
ret = xmlTextWriterEndElement (local->writer);
XML_RET_CHECK_AND_GOTO (ret, out);
- j++;
+ } else {
+ while (j <= brick_count) {
+ ret = xmlTextWriterStartElement
+ (local->writer, (xmlChar *)"brick");
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
+ memset (key, 0, sizeof (key));
+ snprintf (key, sizeof (key),
+ "volume%d.brick%d.uuid", i, j);
+ ret = dict_get_str (dict, key, &uuid);
+ if (ret)
+ goto out;
+ ret = xmlTextWriterWriteFormatAttribute
+ (local->writer, (xmlChar *)"uuid", "%s",
+ uuid);
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
+ memset (key, 0, sizeof (key));
+ snprintf (key, sizeof (key),
+ "volume%d.brick%d", i, j);
+ ret = dict_get_str (dict, key, &brick);
+ if (ret)
+ goto out;
+ ret = xmlTextWriterWriteFormatString
+ (local->writer, "%s", brick);
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
+ ret = xmlTextWriterWriteFormatElement
+ (local->writer, (xmlChar *)"name", "%s",
+ brick);
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
+ ret = xmlTextWriterWriteFormatElement
+ (local->writer, (xmlChar *)"hostUuid",
+ "%s", uuid);
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
+ /* </brick> */
+ ret = xmlTextWriterEndElement (local->writer);
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
+ j++;
+ }
}
/* </bricks> */
ret = xmlTextWriterEndElement (local->writer);
diff --git a/cli/src/cli.h b/cli/src/cli.h
index f5441c07ec0..5671f64ae93 100644
--- a/cli/src/cli.h
+++ b/cli/src/cli.h
@@ -42,6 +42,19 @@ enum argp_option_keys {
ARGP_PORT_KEY = 'p',
};
+typedef enum {
+ COLD_BRICK_COUNT,
+ COLD_TYPE,
+ COLD_DIST_COUNT,
+ COLD_REPLICA_COUNT,
+ COLD_DISPERSE_COUNT,
+ COLD_REDUNDANCY_COUNT,
+ HOT_BRICK_COUNT,
+ HOT_TYPE,
+ HOT_REPLICA_COUNT,
+ MAX
+} values;
+
#define GLUSTER_MODE_SCRIPT (1 << 0)
#define GLUSTER_MODE_ERR_FATAL (1 << 1)
#define GLUSTER_MODE_XML (1 << 2)