summaryrefslogtreecommitdiffstats
path: root/cli/src/cli-cmd-volume.c
diff options
context:
space:
mode:
authorMohammed Rafi KC <rkavunga@redhat.com>2015-04-28 19:17:40 +0530
committerKaushal M <kaushal@redhat.com>2015-05-04 04:02:47 -0700
commit9e6b521cc98b3ba099c1713639be9180be5b031f (patch)
tree2143cd6e3ccba515423a13cbe3db21192b0e7de8 /cli/src/cli-cmd-volume.c
parent821b1fdc893c0dd603d4c43a0b31f1ea495a46c9 (diff)
tiering/cli: Check replica count and bricks are proper or not
Right now, attach-tier calls parsing function for add-brick. Add-brick does not have any check for brick count and replca count compatibility. Change-Id: I44ec13eadffc003a9ebf8c4eb0193df559933a68 BUG: 1215122 Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com> Reviewed-on: http://review.gluster.org/10428 Reviewed-by: Dan Lambright <dlambrig@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'cli/src/cli-cmd-volume.c')
-rw-r--r--cli/src/cli-cmd-volume.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index 5e1cb75cbed..9340067e256 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -835,6 +835,53 @@ out:
}
int
+cli_tier_validate_replica_type (dict_t *dict, int type)
+{
+
+ int brick_count = -1;
+ int replica_count = 1;
+ int ret = -1;
+
+ ret = dict_get_int32 (dict, "count", &brick_count);
+ if (ret) {
+ gf_log ("cli", GF_LOG_ERROR, "Failed to get brick count");
+ goto out;
+ }
+
+ ret = dict_get_int32 (dict, "replica-count", &replica_count);
+ if (ret) {
+ gf_log ("cli", GF_LOG_DEBUG, "Failed to get replica count. "
+ "Defaulting to one");
+ replica_count = 1;
+ }
+
+ /*
+ * Change the calculation of sub_count once attach-tier support
+ * disperse volume.
+ * sub_count = disperse_count for disperse volume
+ * */
+
+
+ if (brick_count % replica_count) {
+ if (type == GF_CLUSTER_TYPE_REPLICATE)
+ cli_err ("number of bricks is not a multiple of "
+ "replica count");
+ else if (type == GF_CLUSTER_TYPE_DISPERSE)
+ cli_err ("number of bricks is not a multiple of "
+ "disperse count");
+ else
+ cli_err ("number of bricks given doesn't match "
+ "required count");
+
+ ret = -1;
+ goto out;
+ }
+ ret = 0;
+out:
+ return ret;
+}
+
+int
cli_cmd_volume_attach_tier_cbk (struct cli_state *state,
struct cli_cmd_word *word, const char **words,
int wordcount)
@@ -860,6 +907,16 @@ cli_cmd_volume_attach_tier_cbk (struct cli_state *state,
goto out;
}
+ /*
+ * Merge this check when attach-tier has it's own cli parse function.
+ */
+ ret = cli_tier_validate_replica_type (options, type);
+ if (ret) {
+ cli_usage_out (word->pattern);
+ parse_error = 1;
+ goto out;
+ }
+
if (state->mode & GLUSTER_MODE_WIGNORE) {
ret = dict_set_int32 (options, "force", _gf_true);
if (ret) {