From 26800453aacd76e6edc36c078aaacbe7c16aa75e Mon Sep 17 00:00:00 2001 From: Kaushal M Date: Wed, 15 Feb 2012 16:18:25 +0530 Subject: cli: Enable output in XML This patch enables gluster cli to output data in xml format. XML output can be obtained by passing "--xml" as an argument. A new "volume list" command, which lists the volumes present in a cluster, has been added. This can be used for obtaining a quick list of volumes. Several commands, including "volume top", "volume profile", "volume status" and "volume info", "volume list", have custom XML output routines. Other commands use either one of the 2 generic output routines, cli_xml_output_str() & cli_xml_output_dict(). NOTE: When using "all" for "volume status" and "volume info" the XML output will have multiple roots. Change-Id: I6117baa02ec06fda116177dbd401f66521263ac6 BUG: 790713 Signed-off-by: Kaushal M Reviewed-on: http://review.gluster.com/2753 Tested-by: Gluster Build System Reviewed-by: Amar Tumballi Reviewed-by: Vijay Bellur --- cli/src/cli-cmd-volume.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'cli/src/cli-cmd-volume.c') diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index 521e3eb8..9c7a43b9 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -1653,6 +1653,33 @@ out: return ret; } +int +cli_cmd_volume_list_cbk (struct cli_state *state, struct cli_cmd_word *word, + const char **words, int wordcount) +{ + int ret = -1; + call_frame_t *frame = NULL; + rpc_clnt_procedure_t *proc = NULL; + int sent = 0; + + frame = create_frame (THIS, THIS->ctx->pool); + if (!frame) + goto out; + + proc = &cli_rpc_prog->proctable[GLUSTER_CLI_LIST_VOLUME]; + if (proc->fn) { + ret = proc->fn (frame, THIS, NULL); + } + +out: + if (ret) { + cli_cmd_sent_status_get (&sent); + if (sent == 0) + cli_out ("Volume list failed"); + } + + return ret; +} struct cli_cmd volume_cmds[] = { { "volume info [all|]", @@ -1754,6 +1781,10 @@ struct cli_cmd volume_cmds[] = { cli_cmd_volume_statedump_cbk, "perform statedump on bricks"}, + {"volume list", + cli_cmd_volume_list_cbk, + "list all volumes in cluster"}, + { NULL, NULL, NULL } }; -- cgit