diff options
Diffstat (limited to 'cli/src')
-rw-r--r-- | cli/src/cli-cmd-volume.c | 61 | ||||
-rw-r--r-- | cli/src/cli-rpc-ops.c | 61 |
2 files changed, 122 insertions, 0 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index 4dcb99ce26e..f1526abaeb5 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -1790,6 +1790,62 @@ out: return ret; } +int +cli_cmd_volume_label_cbk (struct cli_state *state, struct cli_cmd_word *word, + const char **words, int wordcount) +{ + 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; + cli_local_t *local = NULL; + + frame = create_frame (THIS, THIS->ctx->pool); + if (!frame) + goto out; + + if (wordcount != 4) { + cli_usage_out (word->pattern); + parse_error = 1; + goto out; + } + + options = dict_new(); + if (!options) { + cli_out ("Could not allocate dict for label_volume"); + goto out; + } + + ret = dict_set_str (options, "volname", (char *)words[2]); + if (ret) + goto out; + + ret = dict_set_str (options, "brick", (char *)words[3]); + if (ret) + goto out; + + proc = &cli_rpc_prog->proctable[GLUSTER_CLI_LABEL_VOLUME]; + + CLI_LOCAL_INIT (local, words, frame, options); + + if (proc->fn) { + ret = proc->fn (frame, THIS, options); + } + +out: + if (ret) { + cli_cmd_sent_status_get (&sent); + if ((sent == 0) && (parse_error = 0)) + cli_out ("Volume label failed"); + } + + CLI_STACK_DESTROY (frame); + + return ret; +} + struct cli_cmd volume_cmds[] = { { "volume info [all|<VOLNAME>]", cli_cmd_volume_info_cbk, @@ -1900,6 +1956,11 @@ struct cli_cmd volume_cmds[] = { "Clear locks held on path" }, + {"volume label <VOLNAME> <BRICK>", + cli_cmd_volume_label_cbk, + "Add a volume label to an empty replacement brick" + }, + { NULL, NULL, NULL } }; diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index da239b51ec3..e772137ed3e 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -6253,6 +6253,66 @@ out: return ret; } +int32_t +gf_cli_label_volume_cbk (struct rpc_req *req, struct iovec *iov, int count, + void *myframe) +{ + gf_cli_rsp rsp = {0,}; + int ret = -1; + dict_t *dict = NULL; + + if (-1 == req->rpc_status) + goto out; + ret = xdr_to_generic (*iov, &rsp, + (xdrproc_t)xdr_gf_cli_rsp); + if (ret < 0) { + + gf_log ("cli", GF_LOG_ERROR, "XDR decoding failed"); + goto out; + } + gf_log ("cli", GF_LOG_DEBUG, "Received response to label"); + + if (rsp.op_ret) { + cli_err ("Volume label unsuccessful"); + cli_err ("%s", rsp.op_errstr); + + } else { + cli_out ("Volume label successful"); + + } + + ret = rsp.op_ret; + +out: + if (dict) + dict_unref (dict); + cli_cmd_broadcast_response (ret); + return ret; +} + +int32_t +gf_cli_label_volume (call_frame_t *frame, xlator_t *this, void *data) +{ + gf_cli_req req = {{0,}}; + dict_t *options = NULL; + int ret = -1; + + if (!frame || !this || !data) + goto out; + + options = data; + + ret = cli_to_glusterd (&req, frame, gf_cli_label_volume_cbk, + (xdrproc_t) xdr_gf_cli_req, options, + GLUSTER_CLI_LABEL_VOLUME, this, cli_rpc_prog, + NULL); +out: + gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret); + + GF_FREE (req.dict.dict_val); + return ret; +} + int cli_to_glusterd (gf_cli_req *req, call_frame_t *frame, fop_cbk_fn_t cbkfn, xdrproc_t xdrproc, dict_t *dict, @@ -6364,6 +6424,7 @@ struct rpc_clnt_procedure gluster_cli_actors[GLUSTER_CLI_MAXVALUE] = { #ifdef HAVE_BD_XLATOR [GLUSTER_CLI_BD_OP] = {"BD_OP", gf_cli_bd_op}, #endif + [GLUSTER_CLI_LABEL_VOLUME] = {"LABEL_VOLUME", gf_cli_label_volume}, }; struct rpc_clnt_program cli_prog = { |