From e6b6d1235daa483384d2b0701561b8f3a85be583 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Sat, 20 Apr 2013 16:55:15 +0200 Subject: cli: add a command 'gluster pool list [--xml]' * unlike 'gluster peer status', which lists only info about peers, this command lists localhost also in the list, so the sorted output from all the nodes should match. * made the output script friendly by keeping it one output per line. Change-Id: I853656753b35c617debbcceecbb71c8d6dd3c334 BUG: 764638 Original-review: http://review.gluster.org/4221 Original-author: Amar Tumballi Signed-off-by: Niels de Vos Reviewed-on: http://review.gluster.org/4862 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- cli/src/cli-cmd-peer.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'cli/src/cli-cmd-peer.c') diff --git a/cli/src/cli-cmd-peer.c b/cli/src/cli-cmd-peer.c index 08651e72..263f419a 100644 --- a/cli/src/cli-cmd-peer.c +++ b/cli/src/cli-cmd-peer.c @@ -184,7 +184,7 @@ cli_cmd_peer_status_cbk (struct cli_state *state, struct cli_cmd_word *word, goto out; if (proc->fn) { - ret = proc->fn (frame, THIS, (char *)words[1] ); + ret = proc->fn (frame, THIS, (void *)GF_CLI_LIST_PEERS); } out: @@ -199,6 +199,45 @@ out: return ret; } +int +cli_cmd_pool_list_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; + int sent = 0; + int parse_error = 0; + + if (wordcount != 2) { + cli_usage_out (word->pattern); + parse_error = 1; + goto out; + } + + proc = &cli_rpc_prog->proctable[GLUSTER_CLI_LIST_FRIENDS]; + + frame = create_frame (THIS, THIS->ctx->pool); + if (!frame) + goto out; + + if (proc->fn) { + ret = proc->fn (frame, THIS, + (void *)GF_CLI_LIST_POOL_NODES); + } + +out: + if (ret) { + cli_cmd_sent_status_get (&sent); + if ((sent == 0) && (parse_error == 0)) + cli_err ("pool list: command execution failed"); + } + + CLI_STACK_DESTROY (frame); + + return ret; +} + struct cli_cmd cli_probe_cmds[] = { { "peer probe ", cli_cmd_peer_probe_cbk, @@ -216,6 +255,10 @@ struct cli_cmd cli_probe_cmds[] = { cli_cmd_peer_help_cbk, "Help command for peer "}, + { "pool list", + cli_cmd_pool_list_cbk, + "list all the nodes in the pool (including localhost)"}, + { NULL, NULL, NULL } }; -- cgit