summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorGaurav Kumar Garg <ggarg@redhat.com>2015-03-27 15:20:03 +0530
committerKaushal M <kaushal@redhat.com>2015-05-07 00:08:07 -0700
commitf9ebf5ab3cbec423f75e64c25385125d4b65e31b (patch)
treebc2d9d1c0698371d1480c2e0eae09c61e248e61f /cli
parent2d919eab43dfbcfbaa2617b161f3f4bdd1381e96 (diff)
glusterd: remove replace brick with data migration support form cli/glusterd
Replace-brick operation with data migration support have been deprecated from gluster. With this fix replace brick command will support only one commad gluster volume replace-brick <VOLNAME> <SOURCE-BRICK> <NEW-BRICK> {commit force} Change-Id: Ib81d49e5d8e7eaa4ccb5830cfec2bc081191b43b BUG: 1218602 Signed-off-by: Gaurav Kumar Garg <ggarg@redhat.com> Reviewed-on: http://review.gluster.org/10577 Tested-by: Gluster Build System <jenkins@build.gluster.com> Tested-by: NetBSD Build System Reviewed-by: Kaushal M <kaushal@redhat.com>
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-cmd-parser.c100
-rw-r--r--cli/src/cli-cmd-volume.c36
-rw-r--r--cli/src/cli-rpc-ops.c130
-rw-r--r--cli/src/cli-xml-output.c106
-rw-r--r--cli/src/cli.h4
5 files changed, 41 insertions, 335 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index 178ba1bc641..d4aa61ca6b8 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -1752,44 +1752,36 @@ out:
int32_t
cli_cmd_volume_replace_brick_parse (const char **words, int wordcount,
- dict_t **options)
+ dict_t **options)
{
- dict_t *dict = NULL;
- char *volname = NULL;
- int ret = -1;
- int op_index = 0;
- char *delimiter = NULL;
- gf1_cli_replace_op replace_op = GF_REPLACE_OP_NONE;
- char *opwords[] = { "start", "commit", "pause", "abort", "status",
- NULL };
- char *w = NULL;
- gf_boolean_t is_force = _gf_false;
+ int ret = -1;
+ char *volname = NULL;
+ char *delimiter = NULL;
+ dict_t *dict = NULL;
GF_ASSERT (words);
GF_ASSERT (options);
- dict = dict_new ();
-
- if (!dict)
+ if (wordcount != 7) {
+ ret = -1;
goto out;
+ }
- if (wordcount < 3)
+ dict = dict_new ();
+
+ if (!dict) {
+ gf_log ("cli", GF_LOG_ERROR, "Failed to allocate dictionary");
goto out;
+ }
volname = (char *)words[2];
GF_ASSERT (volname);
ret = dict_set_str (dict, "volname", volname);
-
if (ret)
goto out;
- if (wordcount < 4) {
- ret = -1;
- goto out;
- }
-
if (validate_brick_name ((char *)words[3])) {
cli_err ("wrong brick type: %s, use "
"<HOSTNAME>:<export-dir-abs-path>", words[3]);
@@ -1801,16 +1793,11 @@ cli_cmd_volume_replace_brick_parse (const char **words, int wordcount,
if (ret)
goto out;
}
- ret = dict_set_str (dict, "src-brick", (char *)words[3]);
+ ret = dict_set_str (dict, "src-brick", (char *)words[3]);
if (ret)
goto out;
- if (wordcount < 5) {
- ret = -1;
- goto out;
- }
-
if (validate_brick_name ((char *)words[4])) {
cli_err ("wrong brick type: %s, use "
"<HOSTNAME>:<export-dir-abs-path>", words[4]);
@@ -1823,69 +1810,20 @@ cli_cmd_volume_replace_brick_parse (const char **words, int wordcount,
goto out;
}
-
ret = dict_set_str (dict, "dst-brick", (char *)words[4]);
-
if (ret)
goto out;
- op_index = 5;
- if ((wordcount < (op_index + 1))) {
- ret = -1;
- goto out;
- }
-
- w = str_getunamb (words[op_index], opwords);
-
- if (!w) {
- } else if (!strcmp ("start", w)) {
- replace_op = GF_REPLACE_OP_START;
- } else if (!strcmp ("commit", w)) {
- replace_op = GF_REPLACE_OP_COMMIT;
- } else if (!strcmp ("pause", w)) {
- replace_op = GF_REPLACE_OP_PAUSE;
- } else if (!strcmp ("abort", w)) {
- replace_op = GF_REPLACE_OP_ABORT;
- } else if (!strcmp ("status", w)) {
- replace_op = GF_REPLACE_OP_STATUS;
- } else
- GF_ASSERT (!"opword mismatch");
-
/* commit force option */
-
- op_index = 6;
-
- if (wordcount > (op_index + 1)) {
+ if (strcmp ("commit", words[5]) || strcmp ("force", words[6])) {
+ cli_err ("Invalid option '%s' '%s' for replace-brick. Please "
+ "enter valid replace-brick command", words[5],
+ words[6]);
ret = -1;
goto out;
}
- if (wordcount == (op_index + 1)) {
- if ((replace_op != GF_REPLACE_OP_COMMIT) &&
- (replace_op != GF_REPLACE_OP_START)) {
- ret = -1;
- goto out;
- }
- if (!strcmp ("force", words[op_index])) {
- if (replace_op == GF_REPLACE_OP_COMMIT)
- replace_op = GF_REPLACE_OP_COMMIT_FORCE;
-
- else if (replace_op == GF_REPLACE_OP_START)
- is_force = _gf_true;
- }
- }
-
- if (replace_op == GF_REPLACE_OP_NONE) {
- ret = -1;
- goto out;
- }
-
- ret = dict_set_int32 (dict, "operation", (int32_t) replace_op);
-
- if (ret)
- goto out;
-
- ret = dict_set_int32 (dict, "force", is_force);
+ ret = dict_set_str (dict, "operation", "GF_REPLACE_OP_COMMIT_FORCE");
if (ret)
goto out;
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index c731284cdfe..6458d04208d 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -1584,18 +1584,13 @@ cli_cmd_volume_replace_brick_cbk (struct cli_state *state,
const char **words,
int wordcount)
{
- int ret = -1;
- rpc_clnt_procedure_t *proc = NULL;
- call_frame_t *frame = NULL;
+ int ret = -1;
+ rpc_clnt_procedure_t *proc = NULL;
+ call_frame_t *frame = NULL;
dict_t *options = NULL;
- int sent = 0;
- int parse_error = 0;
+ int sent = 0;
+ int parse_error = 0;
cli_local_t *local = NULL;
- int replace_op = 0;
- char *q = "All replace-brick commands except "
- "commit force are deprecated. "
- "Do you want to continue?";
- gf_answer_t answer = GF_ANSWER_NO;
#ifdef GF_SOLARIS_HOST_OS
cli_out ("Command not supported on Solaris");
@@ -1615,24 +1610,6 @@ cli_cmd_volume_replace_brick_cbk (struct cli_state *state,
goto out;
}
- ret = dict_get_int32 (options, "operation", &replace_op);
- if (replace_op != GF_REPLACE_OP_COMMIT_FORCE) {
- answer = cli_cmd_get_confirmation (state, q);
- if (GF_ANSWER_NO == answer) {
- ret = 0;
- goto out;
- }
- }
-
- if (state->mode & GLUSTER_MODE_WIGNORE) {
- ret = dict_set_int32 (options, "force", _gf_true);
- if (ret) {
- gf_log ("cli", GF_LOG_ERROR, "Failed to set force"
- "option");
- goto out;
- }
- }
-
CLI_LOCAL_INIT (local, words, frame, options);
if (proc->fn) {
@@ -2532,7 +2509,8 @@ struct cli_cmd volume_cmds[] = {
cli_cmd_volume_defrag_cbk,
"rebalance operations"},
- { "volume replace-brick <VOLNAME> <BRICK> <NEW-BRICK> {start [force]|pause|abort|status|commit [force]}",
+ { "volume replace-brick <VOLNAME> <SOURCE-BRICK> <NEW-BRICK> "
+ "{commit force}",
cli_cmd_volume_replace_brick_cbk,
"replace-brick operations"},
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 87b0a284457..07fb8dc7e67 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -2308,8 +2308,6 @@ out:
return ret;
}
-
-
int
gf_cli_replace_brick_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
@@ -2322,11 +2320,11 @@ gf_cli_replace_brick_cbk (struct rpc_req *req, struct iovec *iov,
char *src_brick = NULL;
char *dst_brick = NULL;
char *status_reply = NULL;
- gf1_cli_replace_op replace_op = 0;
char *rb_operation_str = NULL;
dict_t *rsp_dict = NULL;
char msg[1024] = {0,};
char *task_id_str = NULL;
+ char *replace_op = 0;
if (-1 == req->rpc_status) {
goto out;
@@ -2345,9 +2343,9 @@ gf_cli_replace_brick_cbk (struct rpc_req *req, struct iovec *iov,
GF_ASSERT (local);
dict = local->dict;
- ret = dict_get_int32 (dict, "operation", (int32_t *)&replace_op);
+ ret = dict_get_str (dict, "operation", &replace_op);
if (ret) {
- gf_log ("", GF_LOG_DEBUG,
+ gf_log (frame->this->name, GF_LOG_ERROR,
"dict_get on operation failed");
goto out;
}
@@ -2360,101 +2358,23 @@ gf_cli_replace_brick_cbk (struct rpc_req *req, struct iovec *iov,
rsp.dict.dict_len,
&rsp_dict);
if (ret < 0) {
- gf_log ("glusterd", GF_LOG_ERROR,
- "failed to "
- "unserialize rsp buffer to dictionary");
+ gf_log (frame->this->name, GF_LOG_ERROR, "failed to "
+ "unserialize rsp buffer to dictionary");
goto out;
}
}
- switch (replace_op) {
- case GF_REPLACE_OP_START:
- if (rsp.op_ret) {
- rb_operation_str = gf_strdup ("replace-brick failed to"
- " start");
- } else {
- ret = dict_get_str (rsp_dict, GF_REPLACE_BRICK_TID_KEY,
- &task_id_str);
- if (ret) {
- gf_log ("cli", GF_LOG_ERROR, "Failed to get "
- "\"replace-brick-id\" from dict");
- goto out;
- }
- ret = gf_asprintf (&rb_operation_str,
- "replace-brick started successfully"
- "\nID: %s", task_id_str);
- if (ret < 0)
- goto out;
- }
- break;
-
- case GF_REPLACE_OP_STATUS:
-
- if (rsp.op_ret || ret) {
- rb_operation_str = gf_strdup ("replace-brick status "
- "unknown");
- } else {
- ret = dict_get_str (rsp_dict, "status-reply",
- &status_reply);
- if (ret) {
- gf_log (frame->this->name, GF_LOG_ERROR, "failed to"
- "get status");
- goto out;
- }
-
- rb_operation_str = gf_strdup (status_reply);
- }
-
- break;
-
- case GF_REPLACE_OP_PAUSE:
- if (rsp.op_ret)
- rb_operation_str = gf_strdup ("replace-brick pause "
- "failed");
- else
- rb_operation_str = gf_strdup ("replace-brick paused "
- "successfully");
- break;
-
- case GF_REPLACE_OP_ABORT:
- if (rsp.op_ret)
- rb_operation_str = gf_strdup ("replace-brick abort "
- "failed");
- else
- rb_operation_str = gf_strdup ("replace-brick aborted "
- "successfully");
- break;
-
- case GF_REPLACE_OP_COMMIT:
- case GF_REPLACE_OP_COMMIT_FORCE:
- ret = dict_get_str (dict, "src-brick", &src_brick);
- if (ret) {
- gf_log ("", GF_LOG_DEBUG,
- "dict_get on src-brick failed");
- goto out;
- }
-
- ret = dict_get_str (dict, "dst-brick", &dst_brick);
- if (ret) {
- gf_log ("", GF_LOG_DEBUG,
- "dict_get on dst-brick failed");
- goto out;
- }
-
+ if (!strcmp(replace_op, "GF_REPLACE_OP_COMMIT_FORCE")) {
if (rsp.op_ret || ret)
rb_operation_str = gf_strdup ("replace-brick commit "
- "failed");
+ "force operation failed");
else
rb_operation_str = gf_strdup ("replace-brick commit "
+ "force operation "
"successful");
-
- break;
-
- default:
- gf_log ("", GF_LOG_DEBUG,
- "Unknown operation");
- break;
+ } else {
+ gf_log (frame->this->name, GF_LOG_DEBUG, "Unknown operation");
}
if (rsp.op_ret && (strcmp (rsp.op_errstr, ""))) {
@@ -6900,35 +6820,7 @@ cli_print_volume_status_tasks (dict_t *dict)
snprintf (task, sizeof (task), "task%d", i);
- /*
- Replace brick only has two states - In progress and Complete
- Ref: xlators/mgmt/glusterd/src/glusterd-replace-brick.c
- */
-
- if (!strcmp (op, "Replace brick")) {
- if (status)
- status = GF_DEFRAG_STATUS_COMPLETE;
- else
- status = GF_DEFRAG_STATUS_STARTED;
-
- memset (key, 0, sizeof (key));
- snprintf (key, sizeof (key), "%s.src-brick", task);
- ret = dict_get_str (dict, key, &src_brick);
- if (ret)
- goto out;
-
- cli_out ("%-20s : %-20s", "Source Brick", src_brick);
-
- memset (key, 0, sizeof (key));
- snprintf (key, sizeof (key), "%s.dst-brick", task);
- ret = dict_get_str (dict, key, &dest_brick);
- if (ret)
- goto out;
-
- cli_out ("%-20s : %-20s", "Destination Brick",
- dest_brick);
-
- } else if (!strcmp (op, "Remove brick")) {
+ if (!strcmp (op, "Remove brick")) {
memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.count", task);
ret = dict_get_int32 (dict, key, &count);
diff --git a/cli/src/cli-xml-output.c b/cli/src/cli-xml-output.c
index d7322d5bb0d..f9013ed2726 100644
--- a/cli/src/cli-xml-output.c
+++ b/cli/src/cli-xml-output.c
@@ -1480,46 +1480,6 @@ out:
}
int
-cli_xml_output_replace_brick_task_params (xmlTextWriterPtr writer, dict_t *dict,
- char *prefix)
-{
-
- int ret = -1;
- char key[1024] = {0,};
- char *brick = NULL;
-
- /* <params> */
- ret = xmlTextWriterStartElement (writer, (xmlChar *)"params");
- XML_RET_CHECK_AND_GOTO (ret, out);
-
- snprintf (key, sizeof (key), "%s.src-brick", prefix);
- ret = dict_get_str (dict, key, &brick);
- if (ret)
- goto out;
- ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"srcBrick",
- "%s", brick);
- XML_RET_CHECK_AND_GOTO (ret, out);
-
-
- memset (key, 0, sizeof (key));
- snprintf (key, sizeof (key), "%s.dst-brick", prefix);
- ret = dict_get_str (dict, key, &brick);
- if (ret)
- goto out;
- ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"dstBrick",
- "%s", brick);
- XML_RET_CHECK_AND_GOTO (ret, out);
-
-
- /* </param> */
- ret = xmlTextWriterEndElement (writer);
-
-out:
- gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret);
- return ret;
-}
-
-int
cli_xml_output_vol_status_tasks (cli_local_t *local, dict_t *dict) {
int ret = -1;
char *task_type = NULL;
@@ -1573,14 +1533,6 @@ cli_xml_output_vol_status_tasks (cli_local_t *local, dict_t *dict) {
"%d", status);
XML_RET_CHECK_AND_GOTO (ret, out);
- if (!strcmp (task_type, "Replace brick")) {
- if (status) {
- status = GF_DEFRAG_STATUS_COMPLETE;
- } else {
- status = GF_DEFRAG_STATUS_STARTED;
- }
- }
-
ret = xmlTextWriterWriteFormatElement (local->writer,
(xmlChar *)"statusStr",
"%s",
@@ -1590,12 +1542,7 @@ cli_xml_output_vol_status_tasks (cli_local_t *local, dict_t *dict) {
memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "task%d", i);
- if (!strcmp (task_type, "Replace brick")) {
- ret = cli_xml_output_replace_brick_task_params
- (local->writer, dict, key);
- if (ret)
- goto out;
- } else if (!strcmp (task_type, "Remove brick")) {
+ if (!strcmp (task_type, "Remove brick")) {
ret = cli_xml_output_remove_brick_task_params
(local->writer, dict, key);
if (ret)
@@ -3476,7 +3423,7 @@ out:
}
int
-cli_xml_output_vol_replace_brick (gf1_cli_replace_op op, dict_t *dict,
+cli_xml_output_vol_replace_brick (char *op, dict_t *dict,
int op_ret, int op_errno, char *op_errstr)
{
#if (HAVE_LIB_XML)
@@ -3496,55 +3443,6 @@ cli_xml_output_vol_replace_brick (gf1_cli_replace_op op, dict_t *dict,
if (ret)
goto out;
- /* <volReplaceBrick> */
- ret = xmlTextWriterStartElement (writer, (xmlChar *)"volReplaceBrick");
- XML_RET_CHECK_AND_GOTO (ret, out);
-
- ret = dict_get_str (dict, GF_REPLACE_BRICK_TID_KEY, &task_id_str);
- if (ret == 0) {
- ret = xmlTextWriterWriteFormatElement (writer,
- (xmlChar *)"task-id",
- "%s", task_id_str);
- XML_RET_CHECK_AND_GOTO (ret, out);
- }
-
- ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"op",
- "%d", op);
- XML_RET_CHECK_AND_GOTO (ret, out);
-
- if (GF_REPLACE_OP_STATUS == op) {
- ret = dict_get_int32 (dict, "status", &status);
- if (ret)
- goto out;
- ret = xmlTextWriterWriteFormatElement (writer,
- (xmlChar *)"status",
- "%d", status);
- XML_RET_CHECK_AND_GOTO (ret, out);
-
- ret = dict_get_uint64 (dict, "files", &files);
- if (ret)
- goto out;
- ret = xmlTextWriterWriteFormatElement (writer,
- (xmlChar *)"files",
- "%"PRIu64, files);
- XML_RET_CHECK_AND_GOTO (ret, out);
-
- if (status)
- goto cont;
-
- ret = dict_get_str (dict, "current_file", &current_file);
- if (ret)
- goto out;
- ret = xmlTextWriterWriteFormatElement (writer,
- (xmlChar *)"currentFile",
- "%s", current_file);
- XML_RET_CHECK_AND_GOTO (ret, out);
- }
-cont:
- /* </volReplaceBrick> */
- ret = xmlTextWriterEndElement (writer);
- XML_RET_CHECK_AND_GOTO (ret, out);
-
ret = cli_end_xml_output (writer, doc);
out:
diff --git a/cli/src/cli.h b/cli/src/cli.h
index 77f951dd25e..a8aa271b68e 100644
--- a/cli/src/cli.h
+++ b/cli/src/cli.h
@@ -400,8 +400,8 @@ cli_xml_output_vol_remove_brick (gf_boolean_t status_op, dict_t *dict,
int op_ret, int op_errno, char *op_errstr);
int
-cli_xml_output_vol_replace_brick (gf1_cli_replace_op op, dict_t *dict,
- int op_ret, int op_errno, char *op_errstr);
+cli_xml_output_vol_replace_brick (char *op, dict_t *dict, int op_ret,
+ int op_errno, char *op_errstr);
int
cli_xml_output_vol_create (dict_t *dict, int op_ret, int op_errno,