diff options
| author | Amar Tumballi <amar@gluster.com> | 2010-08-31 07:51:14 +0000 | 
|---|---|---|
| committer | Vijay Bellur <vijay@dev.gluster.com> | 2010-08-31 10:49:40 -0700 | 
| commit | 6530488a49ed0c9395b091c42b148091075a9d86 (patch) | |
| tree | 18c85cb3bfa4fc0f0dce0aef27bf6af1ade19af9 /cli/src/cli-cmd-volume.c | |
| parent | da5bf7cf104cd060b2f94d47132029689bfff685 (diff) | |
'gluster volume log' feature added
* 'gluster volume log filename <VOLNAME> [BRICK] <path>'
* 'gluster volume log locate <VOLNAME> [BRICK]'
* 'gluster volume log rotate <VOLUME> [BRICK]'
Signed-off-by: Amar Tumballi <amar@gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>
Diffstat (limited to 'cli/src/cli-cmd-volume.c')
| -rw-r--r-- | cli/src/cli-cmd-volume.c | 145 | 
1 files changed, 145 insertions, 0 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index 1421157c89a..3bbccc900cf 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -515,6 +515,140 @@ cli_cmd_volume_set_transport_cbk (struct cli_state *state,          return 0;  } +void +cli_cmd_log_filename_usage () +{ +        cli_out ("Usage: volume log filename <VOLNAME> [BRICK] <PATH>"); +} + +int +cli_cmd_log_filename_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                  *options = NULL; + +        if (!((wordcount == 5) || (wordcount == 6))) { +               cli_cmd_log_filename_usage (); +               goto out; +        } + +        proc = &cli_rpc_prog->proctable[GF1_CLI_LOG_FILENAME]; + +        frame = create_frame (THIS, THIS->ctx->pool); +        if (!frame) +                goto out; + +        ret = cli_cmd_log_filename_parse (words, wordcount, &options); +        if (ret) +                goto out; + +        if (proc->fn) { +                ret = proc->fn (frame, THIS, options); +        } + +out: +        if (ret) +                cli_out ("setting log filename failed"); + +        if (options) +                dict_destroy (options); + +        return ret; +} + + +void +cli_cmd_log_locate_usage () +{ +        cli_out ("Usage: volume log locate <VOLNAME> [BRICK]"); +} + +int +cli_cmd_log_locate_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                  *options = NULL; + +        if (!((wordcount == 4) || (wordcount == 5))) { +               cli_cmd_log_locate_usage (); +               goto out; +        } + +        proc = &cli_rpc_prog->proctable[GF1_CLI_LOG_LOCATE]; + +        frame = create_frame (THIS, THIS->ctx->pool); +        if (!frame) +                goto out; + +        ret = cli_cmd_log_locate_parse (words, wordcount, &options); +        if (ret) +                goto out; + +        if (proc->fn) { +                ret = proc->fn (frame, THIS, options); +        } + +out: +        if (ret) +                cli_out ("getting log file location information failed"); + +        if (options) +                dict_destroy (options); + + +        return ret; +} + +void +cli_cmd_log_rotate_usage () +{ +        cli_out ("Usage: volume log rotate <VOLNAME> [BRICK]"); +} + +int +cli_cmd_log_rotate_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                  *options = NULL; + +        if (!((wordcount == 4) || (wordcount == 5))) { +               cli_cmd_log_rotate_usage (); +               goto out; +        } + +        proc = &cli_rpc_prog->proctable[GF1_CLI_LOG_ROTATE]; + +        frame = create_frame (THIS, THIS->ctx->pool); +        if (!frame) +                goto out; + +        ret = cli_cmd_log_rotate_parse (words, wordcount, &options); +        if (ret) +                goto out; + +        if (proc->fn) { +                ret = proc->fn (frame, THIS, options); +        } + +out: +        if (ret) +                cli_out ("getting log file location information failed"); + +        if (options) +                dict_destroy (options); + +        return ret; +} +  struct cli_cmd volume_cmds[] = {          { "volume info [all|<VOLNAME>]", @@ -577,6 +711,17 @@ struct cli_cmd volume_cmds[] = {            cli_cmd_volume_help_cbk,            "display help for the volume command"}, +        { "volume log filename <VOLNAME> [BRICK] <PATH>", +          cli_cmd_log_filename_cbk, +         "set the log file for corresponding volume/brick"}, + +        { "volume log locate <VOLNAME> [BRICK]", +          cli_cmd_log_locate_cbk, +         "locate the log file for corresponding volume/brick"}, + +        { "volume log rotate <VOLNAME> [BRICK]", +          cli_cmd_log_rotate_cbk, +         "rotate the log file for corresponding volume/brick"},          { NULL, NULL, NULL }  };  | 
