diff options
author | Vijay Bellur <vijay@gluster.com> | 2011-08-18 23:19:22 +0530 |
---|---|---|
committer | Anand Avati <avati@gluster.com> | 2011-08-19 01:29:18 -0700 |
commit | 0143a2ef653d0f7a337c8220f127655dadbca942 (patch) | |
tree | 61896872f41f8ccb39b692a521a62569516bab2d /cli/src/cli-cmd-volume.c | |
parent | d2849bd349081b332540713cfeaa561f57356b2a (diff) |
mgmt/glusterd, cli: Introduce gluster volume status <volname>
Change-Id: Iea835b9e448e736016da2e44e3c9bfff93f2fa78
BUG: 3439
Reviewed-on: http://review.gluster.com/259
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@gluster.com>
Diffstat (limited to 'cli/src/cli-cmd-volume.c')
-rw-r--r-- | cli/src/cli-cmd-volume.c | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index ab7f1ddc7b3..b61eb31c0bc 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -1211,6 +1211,74 @@ cli_cmd_log_level_cbk (struct cli_state *state, struct cli_cmd_word *word, return ret; } +int +cli_cmd_volume_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; + dict_t *dict = NULL; + int parse_error = 0; + + if (wordcount != 3) { + cli_usage_out (word->pattern); + parse_error = 1; + goto out; + } + + proc = &cli_rpc_prog->proctable[GLUSTER_CLI_STATUS_VOLUME]; + + frame = create_frame (THIS, THIS->ctx->pool); + if (!frame) + goto out; + + ret = cli_cmd_volume_status_parse (words, wordcount, &dict); + if (ret) + goto out; + + if (proc->fn) + ret = proc->fn (frame, THIS, dict); + + out: + return ret; +} + + +int +cli_print_brick_status (char *brick, int port, int online, int pid) +{ + int fieldlen = CLI_VOL_STATUS_BRICK_LEN; + char buf[80] = {0,}; + int bricklen = 0; + int i = 0; + char *p = NULL; + int num_tabs = 0; + + bricklen = strlen (brick); + p = brick; + while (bricklen > 0) { + if (bricklen > fieldlen) { + i++; + strncpy (buf, p, fieldlen); + buf[strlen(buf) + 1] = '\0'; + cli_out ("%s", buf); + p = brick + i * fieldlen; + bricklen -= fieldlen; + } else { + num_tabs = (fieldlen - bricklen) / CLI_TAB_LENGTH + 1; + printf ("%s", p); + while (num_tabs-- != 0) + printf ("\t"); + cli_out ("%d\t%c\t%d", port, online?'Y':'N', pid); + bricklen = 0; + } + } + + return 0; +} + struct cli_cmd volume_cmds[] = { { "volume info [all|<VOLNAME>]", cli_cmd_volume_info_cbk, @@ -1309,6 +1377,10 @@ struct cli_cmd volume_cmds[] = { cli_cmd_log_level_cbk, "log level for translator"}, + { "volume status <VOLNAME>", + cli_cmd_volume_status_cbk, + "display status of specified volume"}, + { NULL, NULL, NULL } }; |