summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
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)