summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorPranith Kumar K <pranithk@gluster.com>2010-09-22 04:21:02 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-09-22 04:14:32 -0700
commitd42f248c58b2ca73fb56a3e091c8e967e2435546 (patch)
treec7fb8d6a35206faa42e8d008f37a8aa2fc0a42e0 /cli
parentf47b0c55de9941823fbefe4b3a7e37179d6d4329 (diff)
mgmt/glusterd: replace-brick validations
Signed-off-by: Pranith Kumar K <pranithk@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 1657 (validations for replace-brick while stage op) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1657
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-cmd-parser.c59
-rw-r--r--cli/src/cli-cmd-volume.c2
-rw-r--r--cli/src/cli3_1-cops.c3
3 files changed, 35 insertions, 29 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index 2b7cdd9f6..9de13e56c 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -729,42 +729,45 @@ cli_cmd_volume_replace_brick_parse (const char **words, int wordcount,
}
delimiter = strchr ((char *)words[3], ':');
- if (delimiter && delimiter != words[3]
- && *(delimiter+1) == '/') {
+ if (!delimiter || delimiter == words[3]
+ || *(delimiter+1) != '/') {
+ cli_out ("wrong brick type: %s, use "
+ "<HOSTNAME>:<export-dir-abs-path>", words[3]);
+ ret = -1;
+ goto out;
+ } else {
cli_path_strip_trailing_slashes (delimiter + 1);
- ret = dict_set_str (dict, "src-brick", (char *)words[3]);
-
- if (ret)
- goto out;
+ }
+ ret = dict_set_str (dict, "src-brick", (char *)words[3]);
- if (wordcount < 5) {
- ret = -1;
- goto out;
- }
+ if (ret)
+ goto out;
- delimiter = strchr ((char *)words[4], ':');
- if (!delimiter || delimiter == words[4]
- || *(delimiter+1) != '/') {
- cli_out ("wrong brick type: %s, use "
- "<HOSTNAME>:<export-dir-abs-path>", words[4]);
- ret = -1;
- goto out;
- } else {
- cli_path_strip_trailing_slashes (delimiter + 1);
- }
+ if (wordcount < 5) {
+ ret = -1;
+ goto out;
+ }
+ delimiter = strchr ((char *)words[4], ':');
+ if (!delimiter || delimiter == words[4]
+ || *(delimiter+1) != '/') {
+ cli_out ("wrong brick type: %s, use "
+ "<HOSTNAME>:<export-dir-abs-path>", words[4]);
+ ret = -1;
+ goto out;
+ } else {
+ cli_path_strip_trailing_slashes (delimiter + 1);
+ }
- ret = dict_set_str (dict, "dst-brick", (char *)words[4]);
- if (ret)
- goto out;
+ ret = dict_set_str (dict, "dst-brick", (char *)words[4]);
- op_index = 5;
- } else {
- op_index = 3;
- }
+ if (ret)
+ goto out;
- if (wordcount < (op_index + 1)) {
+ op_index = 5;
+ if ((wordcount < (op_index + 1)) ||
+ (wordcount > (op_index + 1))) {
ret = -1;
goto out;
}
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index 28104c187..c83451778 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -611,7 +611,7 @@ void
cli_cmd_volume_replace_brick_usage ()
{
cli_out("Usage: volume replace-brick <VOLNAME> "
- "(<BRICK> <NEW-BRICK>) start|pause|abort|status");
+ "<BRICK> <NEW-BRICK> start|pause|abort|status");
}
diff --git a/cli/src/cli3_1-cops.c b/cli/src/cli3_1-cops.c
index 53b80c556..78683ccab 100644
--- a/cli/src/cli3_1-cops.c
+++ b/cli/src/cli3_1-cops.c
@@ -937,6 +937,9 @@ gf_cli3_1_replace_brick_cbk (struct rpc_req *req, struct iovec *iov,
break;
}
+ if (rsp.op_ret && (strcmp (rsp.op_errstr, ""))) {
+ rb_operation_str = rsp.op_errstr;
+ }
gf_log ("cli", GF_LOG_NORMAL, "Received resp to replace brick");
cli_out ("%s",