diff options
| author | Gaurav Kumar Garg <ggarg@redhat.com> | 2015-04-15 12:32:11 +0530 | 
|---|---|---|
| committer | Kaushal M <kaushal@redhat.com> | 2015-04-23 23:29:26 -0700 | 
| commit | ec6ccda3783e9a3edd5a2e4093e07ee37f266520 (patch) | |
| tree | 609688226c5ade0158f5cc7f9d0c3c4544d576ca | |
| parent | b6b18e32c820271cbee4770ff79d6c705c112bfa (diff) | |
cli: validate brick while creating replicate volume
When user create replicate volume by typing incomplete command
"gluster volume create <VOLNAME> replica replica_count" then cli
is crashing.
Fix is to validate command properly. If user have not given any brick
then it should return proper cli command usage error message.
Change-Id: I3d4096a144e20f21ab956049af1dae196217a807
BUG: 1211576
Signed-off-by: Gaurav Kumar Garg <ggarg@redhat.com>
Reviewed-on: http://review.gluster.org/10245
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Reviewed-by: Ravishankar N <ravishankar@redhat.com>
Tested-by: NetBSD Build System
Reviewed-by: Kaushal M <kaushal@redhat.com>
Tested-by: Kaushal M <kaushal@redhat.com>
| -rw-r--r-- | cli/src/cli-cmd-parser.c | 38 | 
1 files changed, 21 insertions, 17 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index a1648a9c527..16067f5744b 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -527,24 +527,28 @@ cli_cmd_volume_create_parse (struct cli_state *state, const char **words,                                  goto out;                          index += 2; -                        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; +                        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;                                  } -                                ret = dict_set_int32 (dict, "arbiter-count", -                                                      arbiter_count); -                                if (ret) -                                        goto out; -                                index += 2;                          }                  } else if ((strcmp (w, "stripe")) == 0) {  | 
