diff options
author | Amar Tumballi <amarts@redhat.com> | 2018-06-28 15:47:04 +0530 |
---|---|---|
committer | Atin Mukherjee <amukherj@redhat.com> | 2018-07-03 03:32:20 +0000 |
commit | a585425aad5f07a406da26ba38c59fa0e5ad3036 (patch) | |
tree | 9ec44938bbf0313fd1afd782e82711cccb3f4f6d /cli/src | |
parent | 451fd20fc8be25d8b99d5e8dfcdb43eaa3f94c72 (diff) |
cli: change volume create syntax of arbiter volume
fixes: bz#1596524
updates: gluster/glusterd2#515
Change-Id: I8a46fa2fd1fd2b0e9fbcecd3bb18d348aed9c6a9
Signed-off-by: Amar Tumballi <amarts@redhat.com>
Diffstat (limited to 'cli/src')
-rw-r--r-- | cli/src/cli-cmd-parser.c | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 29043e09810..16b0cc81cd6 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -543,6 +543,7 @@ cli_cmd_volume_create_parse (struct cli_state *state, const char **words, ret = -1; goto out; } + replica_count = strtol (words[index+1], NULL, 0); if (replica_count < 2) { cli_err ("replica count should be greater" @@ -550,6 +551,36 @@ cli_cmd_volume_create_parse (struct cli_state *state, const char **words, ret = -1; goto out; } + + index += 2; + if (words[index]) { + if (!strcmp (words[index], "arbiter")) { + ret = gf_string2int (words[index+1], + &arbiter_count); + if ((ret == -1) || (arbiter_count != 1)) { + cli_err ("For arbiter " + "configuration, " + "replica count must be" + " 2 and arbiter count " + "must be 1. The 3rd " + "brick of the replica " + "will be the arbiter"); + ret = -1; + goto out; + } + ret = dict_set_int32 (dict, "arbiter-count", + arbiter_count); + if (ret) + goto out; + index += 2; + } + } + + /* Do this to keep glusterd happy with sending + "replica 3 arbiter 1" options to server */ + if ((arbiter_count == 1) && (replica_count == 2)) + replica_count += arbiter_count; + if (replica_count == 2) { if (strcmp (words[wordcount - 1], "force")) { question = "Replica 2 volumes are prone" @@ -574,31 +605,6 @@ cli_cmd_volume_create_parse (struct cli_state *state, const char **words, if (ret) goto out; - index += 2; - if (words[index]) { - if (!strcmp (words[index], "arbiter")) { - ret = gf_string2int (words[index+1], - &arbiter_count); - if (ret == -1 || arbiter_count != 1 || - replica_count != 3) { - cli_err ("For arbiter " - "configuration, " - "replica count must be" - " 3 and arbiter count " - "must be 1. The 3rd " - "brick of the replica " - "will be the arbiter"); - ret = -1; - goto out; - } - ret = dict_set_int32 (dict, "arbiter-count", - arbiter_count); - if (ret) - goto out; - index += 2; - } - } - } else if ((strcmp (w, "stripe")) == 0) { switch (type) { case GF_CLUSTER_TYPE_STRIPE_REPLICATE: |