diff options
author | Vijay Bellur <vijay@gluster.com> | 2010-07-12 08:19:44 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2010-07-12 06:59:29 -0700 |
commit | 6ef7f0e25fb7c76231b4d4ae05cbc45330de300d (patch) | |
tree | 6e5b8537dfbee8b7d8e51cdbb62af1d9d0f31a35 /cli/src | |
parent | 9bee476eabb5034a27e994008a12ef684755d76c (diff) |
Changes in CLI and glusterd
Signed-off-by: Vijay Bellur <vijay@gluster.com>
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
BUG: 971 (dynamic volume management)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=971
Diffstat (limited to 'cli/src')
-rw-r--r-- | cli/src/Makefile.am | 3 | ||||
-rw-r--r-- | cli/src/cli-cmd-misc.c | 69 | ||||
-rw-r--r-- | cli/src/cli-cmd-probe.c | 94 | ||||
-rw-r--r-- | cli/src/cli-cmd-volume.c | 24 | ||||
-rw-r--r-- | cli/src/cli-cmd.c | 4 | ||||
-rw-r--r-- | cli/src/cli-cmd.h | 2 | ||||
-rw-r--r-- | cli/src/cli.c | 12 | ||||
-rw-r--r-- | cli/src/cli3_1-cops.c | 310 |
8 files changed, 434 insertions, 84 deletions
diff --git a/cli/src/Makefile.am b/cli/src/Makefile.am index 8e173260325..ee6a675edba 100644 --- a/cli/src/Makefile.am +++ b/cli/src/Makefile.am @@ -1,7 +1,8 @@ sbin_PROGRAMS = gluster gluster_SOURCES = cli.c registry.c input.c cli-cmd.c cli-rl.c \ - cli-cmd-volume.c cli-cmd-probe.c cli3_1-cops.c cli-cmd-parser.c + cli-cmd-volume.c cli-cmd-probe.c cli3_1-cops.c cli-cmd-parser.c\ + cli-cmd-misc.c gluster_LDADD = $(top_builddir)/libglusterfs/src/libglusterfs.la $(GF_LDADD)\ $(RLLIBS) $(top_builddir)/xlators/protocol/lib/src/libgfproto1.la\ diff --git a/cli/src/cli-cmd-misc.c b/cli/src/cli-cmd-misc.c new file mode 100644 index 00000000000..9e78ca607e1 --- /dev/null +++ b/cli/src/cli-cmd-misc.c @@ -0,0 +1,69 @@ +/* + Copyright (c) 2010 Gluster, Inc. <http://www.gluster.com> + This file is part of GlusterFS. + + GlusterFS is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3 of the License, + or (at your option) any later version. + + GlusterFS is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see + <http://www.gnu.org/licenses/>. +*/ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <stdint.h> +#include <pthread.h> + +#ifndef _CONFIG_H +#define _CONFIG_H +#include "config.h" +#endif + +#include "cli.h" +#include "cli-cmd.h" +#include "cli-mem-types.h" +#include "protocol-common.h" + +extern struct rpc_clnt *global_rpc; + +extern rpc_clnt_prog_t *cli_rpc_prog; + +int +cli_cmd_quit_cbk (struct cli_state *state, struct cli_cmd_word *word, + const char **words, int wordcount) +{ + exit (0); +} + +struct cli_cmd cli_misc_cmds[] = { + { "quit", + cli_cmd_quit_cbk }, + + + { NULL, NULL } +}; + + +int +cli_cmd_misc_register (struct cli_state *state) +{ + int ret = 0; + struct cli_cmd *cmd = NULL; + + for (cmd = cli_misc_cmds; cmd->pattern; cmd++) { + ret = cli_cmd_register (&state->tree, cmd->pattern, cmd->cbk); + if (ret) + goto out; + } +out: + return ret; +} diff --git a/cli/src/cli-cmd-probe.c b/cli/src/cli-cmd-probe.c index dccdaedbef9..a9f15a423bf 100644 --- a/cli/src/cli-cmd-probe.c +++ b/cli/src/cli-cmd-probe.c @@ -37,6 +37,24 @@ extern struct rpc_clnt *global_rpc; extern rpc_clnt_prog_t *cli_rpc_prog; +void +cli_cmd_probe_usage () +{ + cli_out ("Usage: probe <hostname>\n"); +} + +void +cli_cmd_deprobe_usage () +{ + cli_out ("Usage: detach <hostname>\n"); +} + +void +cli_cmd_peer_status_usage () +{ + cli_out ("Usage: peer status <hostname>\n"); +} + int cli_cmd_probe_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) @@ -45,7 +63,11 @@ cli_cmd_probe_cbk (struct cli_state *state, struct cli_cmd_word *word, rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; - //cli_out ("probe not implemented\n"); + if (wordcount != 2) { + cli_cmd_probe_usage (); + goto out; + } + proc = &cli_rpc_prog->proctable[GF1_CLI_PROBE]; frame = create_frame (THIS, THIS->ctx->pool); @@ -53,21 +75,83 @@ cli_cmd_probe_cbk (struct cli_state *state, struct cli_cmd_word *word, goto out; if (proc->fn) { - ret = proc->fn (frame, THIS, "localhost"); - } + ret = proc->fn (frame, THIS, (char *)words[1] ); + } + +out: + if (ret) + cli_out ("Probe failed\n"); + return ret; +} + + +int +cli_cmd_deprobe_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; + + if (wordcount != 2) { + cli_cmd_deprobe_usage (); + goto out; + } + + proc = &cli_rpc_prog->proctable[GF1_CLI_DEPROBE]; + + frame = create_frame (THIS, THIS->ctx->pool); + if (!frame) + goto out; + + if (proc->fn) { + ret = proc->fn (frame, THIS, (char *)words[1] ); + } out: if (ret) - cli_out ("Probe failed!"); + cli_out ("Detach failed\n"); return ret; } +int +cli_cmd_peer_status_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; + + if (wordcount != 2) { + cli_cmd_peer_status_usage (); + goto out; + } + + proc = &cli_rpc_prog->proctable[GF1_CLI_LIST_FRIENDS]; + + frame = create_frame (THIS, THIS->ctx->pool); + if (!frame) + goto out; + + if (proc->fn) { + ret = proc->fn (frame, THIS, (char *)words[1] ); + } +out: + if (ret) + cli_out ("Command Execution failed\n"); + return ret; +} struct cli_cmd cli_probe_cmds[] = { - { "probe <VOLNAME>", + { "probe <HOSTNAME>", cli_cmd_probe_cbk }, + { "detach <HOSTNAME>", + cli_cmd_deprobe_cbk }, + + { "peer status", + cli_cmd_peer_status_cbk}, { NULL, NULL } }; diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index 227438db479..dd15a78379c 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -52,7 +52,7 @@ cli_cmd_volume_info_cbk (struct cli_state *state, struct cli_cmd_word *word, if (proc->fn) { ret = proc->fn (frame, THIS, "localhost"); - } + } out: if (ret) @@ -116,7 +116,7 @@ cli_cmd_volume_delete_cbk (struct cli_state *state, struct cli_cmd_word *word, if (proc->fn) { ret = proc->fn (frame, THIS, volname); - } + } out: if (ret) @@ -147,7 +147,7 @@ cli_cmd_volume_start_cbk (struct cli_state *state, struct cli_cmd_word *word, if (proc->fn) { ret = proc->fn (frame, THIS, volname); - } + } out: if (ret) @@ -178,7 +178,7 @@ cli_cmd_volume_stop_cbk (struct cli_state *state, struct cli_cmd_word *word, if (proc->fn) { ret = proc->fn (frame, THIS, volname); - } + } out: if (ret) @@ -224,12 +224,12 @@ cli_cmd_volume_rename_cbk (struct cli_state *state, struct cli_cmd_word *word, if (proc->fn) { ret = proc->fn (frame, THIS, dict); - } + } out: if (ret) { char *volname = (char *) words[2]; - if (dict) + if (dict) dict_destroy (dict); cli_out ("Renaming Volume %s failed", volname ); } @@ -259,7 +259,7 @@ cli_cmd_volume_defrag_cbk (struct cli_state *state, struct cli_cmd_word *word, if (proc->fn) { ret = proc->fn (frame, THIS, volname); - } + } out: if (ret) @@ -290,7 +290,7 @@ cli_cmd_volume_set_cbk (struct cli_state *state, struct cli_cmd_word *word, GF_ASSERT (words[3]); - ret = cli_cmd_volume_set_parse (words, wordcount, &dict); + ret = cli_cmd_volume_set_parse (words, wordcount, &dict); if (ret) goto out; @@ -298,7 +298,7 @@ cli_cmd_volume_set_cbk (struct cli_state *state, struct cli_cmd_word *word, //TODO: Build validation here if (proc->fn) { ret = proc->fn (frame, THIS, dict); - } + } out: if (ret) { @@ -334,7 +334,7 @@ cli_cmd_volume_add_brick_cbk (struct cli_state *state, if (proc->fn) { ret = proc->fn (frame, THIS, options); - } + } out: if (ret) { @@ -368,7 +368,7 @@ cli_cmd_volume_remove_brick_cbk (struct cli_state *state, if (proc->fn) { ret = proc->fn (frame, THIS, options); - } + } out: if (ret) { @@ -406,7 +406,7 @@ cli_cmd_volume_replace_brick_cbk (struct cli_state *state, if (proc->fn) { ret = proc->fn (frame, THIS, options); - } + } out: if (ret) { diff --git a/cli/src/cli-cmd.c b/cli/src/cli-cmd.c index a91dd77e23d..d19703abb45 100644 --- a/cli/src/cli-cmd.c +++ b/cli/src/cli-cmd.c @@ -158,6 +158,10 @@ cli_cmds_register (struct cli_state *state) if (ret) goto out; + ret = cli_cmd_misc_register (state); + if (ret) + goto out; + out: return ret; } diff --git a/cli/src/cli-cmd.h b/cli/src/cli-cmd.h index d1da3e2acd2..4a838151049 100644 --- a/cli/src/cli-cmd.h +++ b/cli/src/cli-cmd.h @@ -36,6 +36,8 @@ int cli_cmd_volume_register (struct cli_state *state); int cli_cmd_probe_register (struct cli_state *state); +int cli_cmd_misc_register (struct cli_state *state); + struct cli_cmd_word *cli_cmd_nextword (struct cli_cmd_word *word, const char *text); void cli_cmd_tokens_destroy (char **tokens); diff --git a/cli/src/cli.c b/cli/src/cli.c index f899fbb72b8..96261de63ca 100644 --- a/cli/src/cli.c +++ b/cli/src/cli.c @@ -249,9 +249,9 @@ logging_init (glusterfs_ctx_t *ctx) } int -cli_submit_request (void *req, call_frame_t *frame, - rpc_clnt_prog_t *prog, - int procnum, struct iobref *iobref, +cli_submit_request (void *req, call_frame_t *frame, + rpc_clnt_prog_t *prog, + int procnum, struct iobref *iobref, cli_serialize_t sfunc, xlator_t *this, fop_cbk_fn_t cbkfn) { @@ -295,8 +295,8 @@ cli_submit_request (void *req, call_frame_t *frame, } /* Send the msg */ - ret = rpc_clnt_submit (global_rpc, prog, procnum, cbkfn, - &iov, count, + ret = rpc_clnt_submit (global_rpc, prog, procnum, cbkfn, + &iov, count, NULL, 0, iobref, frame); if (ret == 0) { @@ -395,7 +395,7 @@ cli_rpc_init (struct cli_state *state) options = dict_new (); if (!options) goto out; - + ret = dict_set_str (options, "remote-host", "localhost"); if (ret) goto out; diff --git a/cli/src/cli3_1-cops.c b/cli/src/cli3_1-cops.c index a3d5ddd8950..4016fee80cb 100644 --- a/cli/src/cli3_1-cops.c +++ b/cli/src/cli3_1-cops.c @@ -34,7 +34,7 @@ extern rpc_clnt_prog_t *cli_rpc_prog; int -gf_cli3_1_probe_cbk (struct rpc_req *req, struct iovec *iov, +gf_cli3_1_probe_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { gf1_cli_probe_rsp rsp = {0,}; @@ -44,7 +44,7 @@ gf_cli3_1_probe_cbk (struct rpc_req *req, struct iovec *iov, goto out; } - ret = gf_xdr_to_cli_probe_req (*iov, &rsp); + ret = gf_xdr_to_cli_probe_rsp (*iov, &rsp); if (ret < 0) { gf_log ("", GF_LOG_ERROR, "error"); //rsp.op_ret = -1; @@ -64,7 +64,137 @@ out: } int -gf_cli3_1_create_volume_cbk (struct rpc_req *req, struct iovec *iov, +gf_cli3_1_deprobe_cbk (struct rpc_req *req, struct iovec *iov, + int count, void *myframe) +{ + gf1_cli_deprobe_rsp rsp = {0,}; + int ret = 0; + + if (-1 == req->rpc_status) { + goto out; + } + + ret = gf_xdr_to_cli_deprobe_req (*iov, &rsp); + if (ret < 0) { + gf_log ("", GF_LOG_ERROR, "error"); + //rsp.op_ret = -1; + //rsp.op_errno = EINVAL; + goto out; + } + + gf_log ("cli", GF_LOG_NORMAL, "Received resp to deprobe"); + cli_out ("Detach %s", (rsp.op_ret) ? "Unsuccessful": "Successful"); + + cli_cmd_broadcast_response (); + + ret = 0; + +out: + return ret; +} + +int +gf_cli3_1_list_friends_cbk (struct rpc_req *req, struct iovec *iov, + int count, void *myframe) +{ + gf1_cli_peer_list_rsp rsp = {0,}; + int ret = 0; + dict_t *dict = NULL; + char *uuid_buf = NULL; + char *hostname_buf = NULL; + int32_t i = 1; + char key[256] = {0,}; + int32_t state = 0; + + if (-1 == req->rpc_status) { + goto out; + } + + ret = gf_xdr_to_cli_peer_list_rsp (*iov, &rsp); + if (ret < 0) { + gf_log ("", GF_LOG_ERROR, "error"); + //rsp.op_ret = -1; + //rsp.op_errno = EINVAL; + goto out; + } + + + gf_log ("cli", GF_LOG_NORMAL, "Received resp to list: %d", + rsp.op_ret); + + if (!rsp.op_ret) { + + if (!rsp.friends.friends_len) { + cli_out ("No peers present"); + goto out; + } + + dict = dict_new (); + + if (!dict) { + ret = -1; + goto out; + } + + ret = dict_unserialize (rsp.friends.friends_val, + rsp.friends.friends_len, + &dict); + + if (ret) { + gf_log ("", GF_LOG_ERROR, + "Unable to allocate memory"); + goto out; + } + + ret = dict_get_int32 (dict, "count", &count); + + if (ret) { + goto out; + } + + cli_out ("Number of Peers: %d", count); + + while ( i <= count) { + snprintf (key, 256, "friend%d.uuid", i); + ret = dict_get_str (dict, key, &uuid_buf); + if (ret) + goto out; + + snprintf (key, 256, "friend%d.hostname", i); + ret = dict_get_str (dict, key, &hostname_buf); + if (ret) + goto out; + + snprintf (key, 256, "friend%d.state", i); + ret = dict_get_int32 (dict, key, &state); + if (ret) + goto out; + + cli_out ("hostname:%s, uuid:%s, state:%d\n", + hostname_buf, uuid_buf, state); + i++; + } + } else { + ret = -1; + goto out; + } + + + ret = 0; + +out: + if (ret) + cli_out ("Command Execution Failed\n"); + + if (dict) + dict_destroy (dict); + + return ret; +} + + +int +gf_cli3_1_create_volume_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { gf1_cli_create_vol_rsp rsp = {0,}; @@ -74,7 +204,7 @@ gf_cli3_1_create_volume_cbk (struct rpc_req *req, struct iovec *iov, goto out; } - ret = gf_xdr_to_cli_create_vol_req (*iov, &rsp); + ret = gf_xdr_to_cli_create_vol_rsp (*iov, &rsp); if (ret < 0) { gf_log ("", GF_LOG_ERROR, "error"); goto out; @@ -82,7 +212,7 @@ gf_cli3_1_create_volume_cbk (struct rpc_req *req, struct iovec *iov, gf_log ("cli", GF_LOG_NORMAL, "Received resp to create volume"); - cli_out ("Create Volume %s", (rsp.op_ret) ? "Unsuccessful": + cli_out ("Create Volume %s", (rsp.op_ret) ? "Unsuccessful": "Successful"); ret = 0; @@ -92,7 +222,7 @@ out: } int -gf_cli3_1_delete_volume_cbk (struct rpc_req *req, struct iovec *iov, +gf_cli3_1_delete_volume_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { gf1_cli_delete_vol_rsp rsp = {0,}; @@ -102,7 +232,7 @@ gf_cli3_1_delete_volume_cbk (struct rpc_req *req, struct iovec *iov, goto out; } - ret = gf_xdr_to_cli_delete_vol_req (*iov, &rsp); + ret = gf_xdr_to_cli_delete_vol_rsp (*iov, &rsp); if (ret < 0) { gf_log ("", GF_LOG_ERROR, "error"); goto out; @@ -110,7 +240,7 @@ gf_cli3_1_delete_volume_cbk (struct rpc_req *req, struct iovec *iov, gf_log ("cli", GF_LOG_NORMAL, "Received resp to delete volume"); - cli_out ("Delete Volume %s", (rsp.op_ret) ? "Unsuccessful": + cli_out ("Delete Volume %s", (rsp.op_ret) ? "Unsuccessful": "Successful"); ret = 0; @@ -120,7 +250,7 @@ out: } int -gf_cli3_1_start_volume_cbk (struct rpc_req *req, struct iovec *iov, +gf_cli3_1_start_volume_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { gf1_cli_start_vol_rsp rsp = {0,}; @@ -130,7 +260,7 @@ gf_cli3_1_start_volume_cbk (struct rpc_req *req, struct iovec *iov, goto out; } - ret = gf_xdr_to_cli_start_vol_req (*iov, &rsp); + ret = gf_xdr_to_cli_start_vol_rsp (*iov, &rsp); if (ret < 0) { gf_log ("", GF_LOG_ERROR, "error"); goto out; @@ -138,7 +268,7 @@ gf_cli3_1_start_volume_cbk (struct rpc_req *req, struct iovec *iov, gf_log ("cli", GF_LOG_NORMAL, "Received resp to start volume"); - cli_out ("Start Volume %s", (rsp.op_ret) ? "Unsuccessful": + cli_out ("Start Volume %s", (rsp.op_ret) ? "Unsuccessful": "Successful"); ret = 0; @@ -148,7 +278,7 @@ out: } int -gf_cli3_1_stop_volume_cbk (struct rpc_req *req, struct iovec *iov, +gf_cli3_1_stop_volume_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { gf1_cli_stop_vol_rsp rsp = {0,}; @@ -158,7 +288,7 @@ gf_cli3_1_stop_volume_cbk (struct rpc_req *req, struct iovec *iov, goto out; } - ret = gf_xdr_to_cli_stop_vol_req (*iov, &rsp); + ret = gf_xdr_to_cli_stop_vol_rsp (*iov, &rsp); if (ret < 0) { gf_log ("", GF_LOG_ERROR, "error"); goto out; @@ -166,7 +296,7 @@ gf_cli3_1_stop_volume_cbk (struct rpc_req *req, struct iovec *iov, gf_log ("cli", GF_LOG_NORMAL, "Received resp to stop volume"); - cli_out ("Delete Volume %s", (rsp.op_ret) ? "Unsuccessful": + cli_out ("Delete Volume %s", (rsp.op_ret) ? "Unsuccessful": "Successful"); ret = 0; @@ -176,7 +306,7 @@ out: } int -gf_cli3_1_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov, +gf_cli3_1_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { gf1_cli_defrag_vol_rsp rsp = {0,}; @@ -186,7 +316,7 @@ gf_cli3_1_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov, goto out; } - ret = gf_xdr_to_cli_defrag_vol_req (*iov, &rsp); + ret = gf_xdr_to_cli_defrag_vol_rsp (*iov, &rsp); if (ret < 0) { gf_log ("", GF_LOG_ERROR, "error"); goto out; @@ -194,7 +324,7 @@ gf_cli3_1_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov, gf_log ("cli", GF_LOG_NORMAL, "Received resp to probe"); - cli_out ("Defrag Volume %s", (rsp.op_ret) ? "Unsuccessful": + cli_out ("Defrag Volume %s", (rsp.op_ret) ? "Unsuccessful": "Successful"); ret = 0; @@ -204,7 +334,7 @@ out: } int -gf_cli3_1_rename_volume_cbk (struct rpc_req *req, struct iovec *iov, +gf_cli3_1_rename_volume_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { gf1_cli_rename_vol_rsp rsp = {0,}; @@ -214,7 +344,7 @@ gf_cli3_1_rename_volume_cbk (struct rpc_req *req, struct iovec *iov, goto out; } - ret = gf_xdr_to_cli_rename_vol_req (*iov, &rsp); + ret = gf_xdr_to_cli_rename_vol_rsp (*iov, &rsp); if (ret < 0) { gf_log ("", GF_LOG_ERROR, "error"); goto out; @@ -222,7 +352,7 @@ gf_cli3_1_rename_volume_cbk (struct rpc_req *req, struct iovec *iov, gf_log ("cli", GF_LOG_NORMAL, "Received resp to probe"); - cli_out ("Rename Volume %s", (rsp.op_ret) ? "Unsuccessful": + cli_out ("Rename Volume %s", (rsp.op_ret) ? "Unsuccessful": "Successful"); ret = 0; @@ -232,7 +362,7 @@ out: } int -gf_cli3_1_set_volume_cbk (struct rpc_req *req, struct iovec *iov, +gf_cli3_1_set_volume_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { gf1_cli_set_vol_rsp rsp = {0,}; @@ -242,7 +372,7 @@ gf_cli3_1_set_volume_cbk (struct rpc_req *req, struct iovec *iov, goto out; } - ret = gf_xdr_to_cli_set_vol_req (*iov, &rsp); + ret = gf_xdr_to_cli_set_vol_rsp (*iov, &rsp); if (ret < 0) { gf_log ("", GF_LOG_ERROR, "error"); goto out; @@ -250,7 +380,7 @@ gf_cli3_1_set_volume_cbk (struct rpc_req *req, struct iovec *iov, gf_log ("cli", GF_LOG_NORMAL, "Received resp to set"); - cli_out ("Set Volume %s", (rsp.op_ret) ? "Unsuccessful": + cli_out ("Set Volume %s", (rsp.op_ret) ? "Unsuccessful": "Successful"); ret = 0; @@ -260,7 +390,7 @@ out: } int -gf_cli3_1_add_brick_cbk (struct rpc_req *req, struct iovec *iov, +gf_cli3_1_add_brick_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { gf1_cli_add_brick_rsp rsp = {0,}; @@ -270,7 +400,7 @@ gf_cli3_1_add_brick_cbk (struct rpc_req *req, struct iovec *iov, goto out; } - ret = gf_xdr_to_cli_add_brick_req (*iov, &rsp); + ret = gf_xdr_to_cli_add_brick_rsp (*iov, &rsp); if (ret < 0) { gf_log ("", GF_LOG_ERROR, "error"); goto out; @@ -278,7 +408,7 @@ gf_cli3_1_add_brick_cbk (struct rpc_req *req, struct iovec *iov, gf_log ("cli", GF_LOG_NORMAL, "Received resp to add brick"); - cli_out ("Add Brick %s", (rsp.op_ret) ? "Unsuccessful": + cli_out ("Add Brick %s", (rsp.op_ret) ? "Unsuccessful": "Successful"); ret = 0; @@ -289,7 +419,7 @@ out: int -gf_cli3_1_remove_brick_cbk (struct rpc_req *req, struct iovec *iov, +gf_cli3_1_remove_brick_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { gf1_cli_remove_brick_rsp rsp = {0,}; @@ -299,14 +429,14 @@ gf_cli3_1_remove_brick_cbk (struct rpc_req *req, struct iovec *iov, goto out; } - ret = gf_xdr_to_cli_remove_brick_req (*iov, &rsp); + ret = gf_xdr_to_cli_remove_brick_rsp (*iov, &rsp); if (ret < 0) { gf_log ("", GF_LOG_ERROR, "error"); goto out; } gf_log ("cli", GF_LOG_NORMAL, "Received resp to remove brick"); - cli_out ("Remove Brick %s", (rsp.op_ret) ? "Unsuccessful": + cli_out ("Remove Brick %s", (rsp.op_ret) ? "Unsuccessful": "Successful"); ret = 0; @@ -317,7 +447,7 @@ out: int -gf_cli3_1_replace_brick_cbk (struct rpc_req *req, struct iovec *iov, +gf_cli3_1_replace_brick_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { gf1_cli_replace_brick_rsp rsp = {0,}; @@ -327,7 +457,7 @@ gf_cli3_1_replace_brick_cbk (struct rpc_req *req, struct iovec *iov, goto out; } - ret = gf_xdr_to_cli_replace_brick_req (*iov, &rsp); + ret = gf_xdr_to_cli_replace_brick_rsp (*iov, &rsp); if (ret < 0) { gf_log ("", GF_LOG_ERROR, "error"); goto out; @@ -335,7 +465,7 @@ gf_cli3_1_replace_brick_cbk (struct rpc_req *req, struct iovec *iov, gf_log ("cli", GF_LOG_NORMAL, "Received resp to replace brick"); - cli_out ("Replace Brick %s", (rsp.op_ret) ? "Unsuccessful": + cli_out ("Replace Brick %s", (rsp.op_ret) ? "Unsuccessful": "Successful"); ret = 0; @@ -345,7 +475,7 @@ out: } int32_t -gf_cli3_1_probe (call_frame_t *frame, xlator_t *this, +gf_cli3_1_probe (call_frame_t *frame, xlator_t *this, void *data) { gf1_cli_probe_req req = {0,}; @@ -374,7 +504,65 @@ out: } int32_t -gf_cli3_1_create_volume (call_frame_t *frame, xlator_t *this, +gf_cli3_1_deprobe (call_frame_t *frame, xlator_t *this, + void *data) +{ + gf1_cli_deprobe_req req = {0,}; + int ret = 0; + char *hostname = NULL; + + if (!frame || !this || !data) { + ret = -1; + goto out; + } + + hostname = data; + + req.hostname = hostname; + + ret = cli_submit_request (&req, frame, cli_rpc_prog, + GD_MGMT_CLI_DEPROBE, NULL, + gf_xdr_from_cli_deprobe_req, + this, gf_cli3_1_deprobe_cbk); + + if (!ret) { + //ret = cli_cmd_await_response (); + } +out: + gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret); + return ret; +} + +int32_t +gf_cli3_1_list_friends (call_frame_t *frame, xlator_t *this, + void *data) +{ + gf1_cli_peer_list_req req = {0,}; + int ret = 0; + + if (!frame || !this) { + ret = -1; + goto out; + } + + req.flags = GF_CLI_LIST_ALL; + + ret = cli_submit_request (&req, frame, cli_rpc_prog, + GD_MGMT_CLI_LIST_FRIENDS, NULL, + gf_xdr_from_cli_peer_list_req, + this, gf_cli3_1_list_friends_cbk); + + if (!ret) { + //ret = cli_cmd_await_response (); + } +out: + gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret); + return ret; +} + + +int32_t +gf_cli3_1_create_volume (call_frame_t *frame, xlator_t *this, void *data) { gf1_cli_create_vol_req req = {0,}; @@ -433,7 +621,7 @@ out: } int32_t -gf_cli3_1_delete_volume (call_frame_t *frame, xlator_t *this, +gf_cli3_1_delete_volume (call_frame_t *frame, xlator_t *this, void *data) { gf1_cli_delete_vol_req req = {0,}; @@ -447,7 +635,7 @@ gf_cli3_1_delete_volume (call_frame_t *frame, xlator_t *this, req.volname = data; ret = cli_submit_request (&req, frame, cli_rpc_prog, - GD_MGMT_CLI_DELETE_VOLUME, NULL, + GD_MGMT_CLI_DELETE_VOLUME, NULL, gf_xdr_from_cli_delete_vol_req, this, gf_cli3_1_delete_volume_cbk); @@ -458,7 +646,7 @@ out: } int32_t -gf_cli3_1_start_volume (call_frame_t *frame, xlator_t *this, +gf_cli3_1_start_volume (call_frame_t *frame, xlator_t *this, void *data) { gf1_cli_start_vol_req req = {0,}; @@ -472,7 +660,7 @@ gf_cli3_1_start_volume (call_frame_t *frame, xlator_t *this, req.volname = data; ret = cli_submit_request (&req, frame, cli_rpc_prog, - GD_MGMT_CLI_START_VOLUME, NULL, + GD_MGMT_CLI_START_VOLUME, NULL, gf_xdr_from_cli_start_vol_req, this, gf_cli3_1_start_volume_cbk); @@ -483,7 +671,7 @@ out: } int32_t -gf_cli3_1_stop_volume (call_frame_t *frame, xlator_t *this, +gf_cli3_1_stop_volume (call_frame_t *frame, xlator_t *this, void *data) { gf1_cli_stop_vol_req req = {0,}; @@ -497,7 +685,7 @@ gf_cli3_1_stop_volume (call_frame_t *frame, xlator_t *this, req.volname = data; ret = cli_submit_request (&req, frame, cli_rpc_prog, - GD_MGMT_CLI_STOP_VOLUME, NULL, + GD_MGMT_CLI_STOP_VOLUME, NULL, gf_xdr_from_cli_stop_vol_req, this, gf_cli3_1_stop_volume_cbk); @@ -508,7 +696,7 @@ out: } int32_t -gf_cli3_1_defrag_volume (call_frame_t *frame, xlator_t *this, +gf_cli3_1_defrag_volume (call_frame_t *frame, xlator_t *this, void *data) { gf1_cli_defrag_vol_req req = {0,}; @@ -522,7 +710,7 @@ gf_cli3_1_defrag_volume (call_frame_t *frame, xlator_t *this, req.volname = data; ret = cli_submit_request (&req, frame, cli_rpc_prog, - GD_MGMT_CLI_DEFRAG_VOLUME, NULL, + GD_MGMT_CLI_DEFRAG_VOLUME, NULL, gf_xdr_from_cli_defrag_vol_req, this, gf_cli3_1_defrag_volume_cbk); @@ -533,7 +721,7 @@ out: } int32_t -gf_cli3_1_rename_volume (call_frame_t *frame, xlator_t *this, +gf_cli3_1_rename_volume (call_frame_t *frame, xlator_t *this, void *data) { gf1_cli_rename_vol_req req = {0,}; @@ -547,18 +735,18 @@ gf_cli3_1_rename_volume (call_frame_t *frame, xlator_t *this, dict = data; - ret = dict_get_str (dict, "old-volname", &req.old_volname); + ret = dict_get_str (dict, "old-volname", &req.old_volname); if (ret) goto out; ret = dict_get_str (dict, "new-volname", &req.new_volname); - + if (ret) goto out; ret = cli_submit_request (&req, frame, cli_rpc_prog, - GD_MGMT_CLI_RENAME_VOLUME, NULL, + GD_MGMT_CLI_RENAME_VOLUME, NULL, gf_xdr_from_cli_rename_vol_req, this, gf_cli3_1_rename_volume_cbk); @@ -569,7 +757,7 @@ out: } int32_t -gf_cli3_1_set_volume (call_frame_t *frame, xlator_t *this, +gf_cli3_1_set_volume (call_frame_t *frame, xlator_t *this, void *data) { gf1_cli_set_vol_req req = {0,}; @@ -583,7 +771,7 @@ gf_cli3_1_set_volume (call_frame_t *frame, xlator_t *this, dict = data; - ret = dict_get_str (dict, "volname", &req.volname); + ret = dict_get_str (dict, "volname", &req.volname); if (ret) goto out; @@ -599,7 +787,7 @@ gf_cli3_1_set_volume (call_frame_t *frame, xlator_t *this, ret = cli_submit_request (&req, frame, cli_rpc_prog, - GD_MGMT_CLI_SET_VOLUME, NULL, + GD_MGMT_CLI_SET_VOLUME, NULL, gf_xdr_from_cli_set_vol_req, this, gf_cli3_1_set_volume_cbk); @@ -610,7 +798,7 @@ out: } int32_t -gf_cli3_1_add_brick (call_frame_t *frame, xlator_t *this, +gf_cli3_1_add_brick (call_frame_t *frame, xlator_t *this, void *data) { gf1_cli_add_brick_req req = {0,}; @@ -624,7 +812,7 @@ gf_cli3_1_add_brick (call_frame_t *frame, xlator_t *this, dict = data; - ret = dict_get_str (dict, "volname", &req.volname); + ret = dict_get_str (dict, "volname", &req.volname); if (ret) goto out; @@ -635,7 +823,7 @@ gf_cli3_1_add_brick (call_frame_t *frame, xlator_t *this, goto out; ret = dict_get_int32 (dict, "count", &req.count); - + if (ret) goto out; @@ -649,7 +837,7 @@ gf_cli3_1_add_brick (call_frame_t *frame, xlator_t *this, } ret = cli_submit_request (&req, frame, cli_rpc_prog, - GD_MGMT_CLI_ADD_BRICK, NULL, + GD_MGMT_CLI_ADD_BRICK, NULL, gf_xdr_from_cli_add_brick_req, this, gf_cli3_1_add_brick_cbk); @@ -664,7 +852,7 @@ out: } int32_t -gf_cli3_1_remove_brick (call_frame_t *frame, xlator_t *this, +gf_cli3_1_remove_brick (call_frame_t *frame, xlator_t *this, void *data) { gf1_cli_remove_brick_req req = {0,}; @@ -678,7 +866,7 @@ gf_cli3_1_remove_brick (call_frame_t *frame, xlator_t *this, dict = data; - ret = dict_get_str (dict, "volname", &req.volname); + ret = dict_get_str (dict, "volname", &req.volname); if (ret) goto out; @@ -689,7 +877,7 @@ gf_cli3_1_remove_brick (call_frame_t *frame, xlator_t *this, goto out; ret = dict_get_int32 (dict, "count", &req.count); - + if (ret) goto out; @@ -703,7 +891,7 @@ gf_cli3_1_remove_brick (call_frame_t *frame, xlator_t *this, } ret = cli_submit_request (&req, frame, cli_rpc_prog, - GD_MGMT_CLI_REMOVE_BRICK, NULL, + GD_MGMT_CLI_REMOVE_BRICK, NULL, gf_xdr_from_cli_remove_brick_req, this, gf_cli3_1_remove_brick_cbk); @@ -718,7 +906,7 @@ out: } int32_t -gf_cli3_1_replace_brick (call_frame_t *frame, xlator_t *this, +gf_cli3_1_replace_brick (call_frame_t *frame, xlator_t *this, void *data) { gf1_cli_replace_brick_req req = {0,}; @@ -734,7 +922,7 @@ gf_cli3_1_replace_brick (call_frame_t *frame, xlator_t *this, dict = data; - ret = dict_get_str (dict, "volname", &req.volname); + ret = dict_get_str (dict, "volname", &req.volname); if (ret) goto out; @@ -763,7 +951,7 @@ gf_cli3_1_replace_brick (call_frame_t *frame, xlator_t *this, } ret = cli_submit_request (&req, frame, cli_rpc_prog, - GD_MGMT_CLI_REPLACE_BRICK, NULL, + GD_MGMT_CLI_REPLACE_BRICK, NULL, gf_xdr_from_cli_replace_brick_req, this, gf_cli3_1_replace_brick_cbk); @@ -784,6 +972,8 @@ out: struct rpc_clnt_procedure gluster3_1_cli_actors[GF1_CLI_MAXVALUE] = { [GF1_CLI_NULL] = {"NULL", NULL }, [GF1_CLI_PROBE] = { "PROBE_QUERY", gf_cli3_1_probe}, + [GF1_CLI_DEPROBE] = { "DEPROBE_QUERY", gf_cli3_1_deprobe}, + [GF1_CLI_LIST_FRIENDS] = { "DEPROBE_QUERY", gf_cli3_1_list_friends}, [GF1_CLI_CREATE_VOLUME] = {"CREATE_VOLUME", gf_cli3_1_create_volume}, [GF1_CLI_DELETE_VOLUME] = {"DELETE_VOLUME", gf_cli3_1_delete_volume}, [GF1_CLI_START_VOLUME] = {"START_VOLUME", gf_cli3_1_start_volume}, |