From afa6e19f6a9e1dde0f00d72c21c760a5dca341b0 Mon Sep 17 00:00:00 2001 From: Csaba Henk Date: Wed, 15 Sep 2010 08:11:20 +0000 Subject: cli: added system:: portmap brick2port Signed-off-by: Csaba Henk Signed-off-by: Vijay Bellur BUG: 1570 (geosync related changes) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1570 --- cli/src/cli-cmd-system.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'cli/src/cli-cmd-system.c') diff --git a/cli/src/cli-cmd-system.c b/cli/src/cli-cmd-system.c index 86e2c167b..08fc44a37 100644 --- a/cli/src/cli-cmd-system.c +++ b/cli/src/cli-cmd-system.c @@ -34,6 +34,7 @@ #include "protocol-common.h" #define GETSPEC_SYNTAX "system:: getspec " +#define BRICKTOPORT_SYNTAX "system:: portmap brick2port " extern struct rpc_clnt *global_rpc; @@ -85,11 +86,58 @@ out: return ret; } +int +cli_cmd_pmap_b2p_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 *dict = NULL; + + frame = create_frame (THIS, THIS->ctx->pool); + if (!frame) + goto out; + + dict = dict_new (); + if (!dict) + goto out; + + if (wordcount != 4) { + cli_out ("Usage: " BRICKTOPORT_SYNTAX); + goto out; + } + + ret = dict_set_str (dict, "brick", (char *)words[3]); + if (ret) + goto out; + + proc = &cli_rpc_prog->proctable[GF1_CLI_PMAP_PORTBYBRICK]; + if (proc->fn) { + ret = proc->fn (frame, THIS, dict); + } + +out: + if (!proc && ret) { + if (dict) + dict_destroy (dict); + if (wordcount > 1) + cli_out ("Fetching spec for volume %s failed", + (char *)words[3]); + } + + return ret; +} + struct cli_cmd cli_system_cmds[] = { { GETSPEC_SYNTAX, cli_cmd_getspec_cbk, "fetch spec for volume "}, + { BRICKTOPORT_SYNTAX, + cli_cmd_pmap_b2p_cbk, + "query which port listens on"}, + { "system:: help", cli_cmd_system_help_cbk, "display help for system commands"}, -- cgit