From 6ef7f0e25fb7c76231b4d4ae05cbc45330de300d Mon Sep 17 00:00:00 2001 From: Vijay Bellur Date: Mon, 12 Jul 2010 08:19:44 +0000 Subject: Changes in CLI and glusterd Signed-off-by: Vijay Bellur Signed-off-by: Anand V. Avati BUG: 971 (dynamic volume management) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=971 --- cli/src/cli-cmd-probe.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 89 insertions(+), 5 deletions(-) (limited to 'cli/src/cli-cmd-probe.c') 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 \n"); +} + +void +cli_cmd_deprobe_usage () +{ + cli_out ("Usage: detach \n"); +} + +void +cli_cmd_peer_status_usage () +{ + cli_out ("Usage: peer status \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 ", + { "probe ", cli_cmd_probe_cbk }, + { "detach ", + cli_cmd_deprobe_cbk }, + + { "peer status", + cli_cmd_peer_status_cbk}, { NULL, NULL } }; -- cgit