From 3e5c243396b6acf1a76d66d80c798466dc5caa55 Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Thu, 2 Sep 2010 05:24:48 +0000 Subject: cli, mgmt/glusterd: Added replace brick cli response Signed-off-by: Pranith Kumar K Signed-off-by: Vijay Bellur BUG: 1322 (Replace brick should show status of paused and abort states) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1322 --- xlators/mgmt/glusterd/src/glusterd-op-sm.c | 33 ++++++++++++++++++++++++++++-- xlators/mgmt/glusterd/src/glusterd-utils.c | 1 + 2 files changed, 32 insertions(+), 2 deletions(-) (limited to 'xlators/mgmt/glusterd/src') diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index b5cd26b8f..b17939374 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -1887,6 +1887,7 @@ rb_do_operation_status (glusterd_volinfo_t *volinfo, { const char *status = NULL; char *status_reply = NULL; + dict_t *ctx = NULL; int ret = -1; if (!glusterd_is_local_addr (src_brickinfo->hostname)) { @@ -1912,6 +1913,13 @@ rb_do_operation_status (glusterd_volinfo_t *volinfo, gf_log ("", GF_LOG_DEBUG, "pump status is %s", status); + ctx = glusterd_op_get_ctx (GD_OP_REPLACE_BRICK); + if (!ctx) { + gf_log ("", GF_LOG_ERROR, + "Operation Context is not present"); + ret = -1; + goto out; + } status_reply = gf_strdup (status); if (!status_reply) { gf_log ("", GF_LOG_ERROR, @@ -1920,11 +1928,11 @@ rb_do_operation_status (glusterd_volinfo_t *volinfo, goto out; } - ret = dict_set_dynstr (dict, "status-reply", + ret = dict_set_dynstr (ctx, "status-reply", status_reply); if (ret) { gf_log ("", GF_LOG_DEBUG, - "failed to set pump status in dict"); + "failed to set pump status in ctx"); goto out; } @@ -2813,6 +2821,7 @@ glusterd_op_send_cli_response (int32_t op, int32_t op_ret, int32_t ret = -1; gd_serialize_t sfunc = NULL; void *cli_rsp = NULL; + dict_t *ctx = NULL; switch (op) { case GD_MGMT_CLI_CREATE_VOLUME: @@ -2895,6 +2904,26 @@ glusterd_op_send_cli_response (int32_t op, int32_t op_ret, break; } + case GD_MGMT_CLI_REPLACE_BRICK: + { + gf1_cli_replace_brick_rsp rsp = {0,}; + ctx = glusterd_op_get_ctx (GD_OP_REPLACE_BRICK); + if (!ctx) { + gf_log ("", GF_LOG_ERROR, + "Operation Context is not present"); + ret = -1; + goto out; + } + if (dict_get_str (ctx, "status-reply", &rsp.status)) + rsp.status = ""; + rsp.op_ret = op_ret; + rsp.op_errno = op_errno; + rsp.volname = ""; + cli_rsp = &rsp; + sfunc = gf_xdr_serialize_cli_replace_brick_rsp; + break; + } + case GD_MGMT_CLI_LOG_FILENAME: { gf1_cli_log_filename_rsp rsp = {0,}; diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 1c456afc6..6bcbf8c0e 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -964,6 +964,7 @@ glusterd_is_cli_op_req (int32_t op) case GD_MGMT_CLI_DEFRAG_VOLUME: case GD_MGMT_CLI_ADD_BRICK: case GD_MGMT_CLI_REMOVE_BRICK: + case GD_MGMT_CLI_REPLACE_BRICK: case GD_MGMT_CLI_LOG_FILENAME: case GD_MGMT_CLI_LOG_LOCATE: case GD_MGMT_CLI_LOG_ROTATE: -- cgit