diff options
Diffstat (limited to 'cli/src/cli-cmd-parser.c')
| -rw-r--r-- | cli/src/cli-cmd-parser.c | 51 | 
1 files changed, 46 insertions, 5 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 9ec4d312e6f..48d6ebd64a7 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -1709,8 +1709,8 @@ out:  }  int32_t -cli_cmd_volume_add_brick_parse (const char **words, int wordcount, -                                dict_t **options, int *ret_type) +cli_cmd_volume_add_brick_parse (struct cli_state *state, const char **words, +                                int wordcount, dict_t **options, int *ret_type)  {          dict_t  *dict = NULL;          char    *volname = NULL; @@ -1725,6 +1725,8 @@ cli_cmd_volume_add_brick_parse (const char **words, int wordcount,          int     index;          gf_boolean_t is_force = _gf_false;          int wc = wordcount; +        gf_answer_t answer = GF_ANSWER_NO; +        const char *question = NULL;          GF_ASSERT (words);          GF_ASSERT (options); @@ -1789,6 +1791,24 @@ cli_cmd_volume_add_brick_parse (const char **words, int wordcount,                                  goto out;                          index = 7;                  } + +                if (count == 2) { +                        if (strcmp (words[wordcount - 1], "force")) { +                                question = "Replica 2 volumes are prone to " +                                           "split-brain. Use Arbiter or " +                                           "Replica 3 to avaoid this. See: " +                                           "http://docs.gluster.org/en/latest/Administrator%20Guide/Split%20brain%20and%20ways%20to%20deal%20with%20it/." +                                           "\nDo you still want to continue?\n"; +                                answer = cli_cmd_get_confirmation (state, +                                                                   question); +                                if (GF_ANSWER_NO == answer) { +                                        gf_log ("cli", GF_LOG_ERROR, "Add brick" +                                                " cancelled, exiting"); +                                        ret = -1; +                                        goto out; +                                } +                        } +                }          } else if ((strcmp (w, "stripe")) == 0) {                  type = GF_CLUSTER_TYPE_STRIPE;                  count = strtol (words[4], NULL, 0); @@ -1992,9 +2012,10 @@ out:  }  int32_t -cli_cmd_volume_remove_brick_parse (const char **words, int wordcount, -                                   dict_t **options, int *question, -                                   int *brick_count, int32_t *comm) +cli_cmd_volume_remove_brick_parse (struct cli_state *state, const char **words, +                                   int wordcount, dict_t **options, +                                   int *question, int *brick_count, +                                   int32_t *comm)  {          dict_t  *dict = NULL;          char    *volname = NULL; @@ -2012,6 +2033,8 @@ cli_cmd_volume_remove_brick_parse (const char **words, int wordcount,          char    *w = NULL;          int32_t  command = GF_OP_CMD_NONE;          long     count = 0; +        gf_answer_t answer = GF_ANSWER_NO; +        const char *ques = NULL;          GF_ASSERT (words);          GF_ASSERT (options); @@ -2046,6 +2069,24 @@ cli_cmd_volume_remove_brick_parse (const char **words, int wordcount,                          goto out;                  } +                if (count == 2) { +                        if (strcmp (words[wordcount - 1], "force")) { +                                ques = "Replica 2 volumes are prone to " +                                       "split-brain. Use Arbiter or Replica 3 " +                                       "to avaoid this. See: " +                                       "http://docs.gluster.org/en/latest/Administrator%20Guide/Split%20brain%20and%20ways%20to%20deal%20with%20it/." +                                       "\nDo you still want to continue?\n"; +                                answer = cli_cmd_get_confirmation (state, +                                                                   ques); +                                if (GF_ANSWER_NO == answer) { +                                        gf_log ("cli", GF_LOG_ERROR, "Remove " +                                                "brick cancelled, exiting"); +                                        ret = -1; +                                        goto out; +                                } +                        } +                } +                  ret = dict_set_int32 (dict, "replica-count", count);                  if (ret)                          goto out;  | 
