diff options
| author | Venky Shankar <venky@gluster.com> | 2011-04-25 03:10:01 +0000 | 
|---|---|---|
| committer | Anand Avati <avati@gluster.com> | 2011-05-20 11:01:49 -0700 | 
| commit | 2cd8411a0278f98ed820aad3e482de079d0540c0 (patch) | |
| tree | 66cd9fa15fe8d269277b41469c3f45a12f59c24b /cli/src | |
| parent | 03c58c782d99440a5947289d0ff216bca8ef7c57 (diff) | |
cli log level command and per translator log level
Signed-off-by: Venky Shankar <venky@gluster.com>
Signed-off-by: Anand Avati <avati@gluster.com>
BUG: 2714 (implement cli log level command)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2714
Diffstat (limited to 'cli/src')
| -rw-r--r-- | cli/src/cli-cmd-parser.c | 55 | ||||
| -rw-r--r-- | cli/src/cli-cmd-volume.c | 37 | ||||
| -rw-r--r-- | cli/src/cli-rpc-ops.c | 69 | ||||
| -rw-r--r-- | cli/src/cli.h | 5 | 
4 files changed, 166 insertions, 0 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 1b3c5ca2d26..d18336e7e28 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -1015,6 +1015,61 @@ out:  }  int32_t +cli_cmd_log_level_parse (const char **words, int worcount, dict_t **options) +{ +        dict_t *dict            = NULL; +        int     ret             = -1; + +        GF_ASSERT (words); +        GF_ASSERT (options); + +        /* +         * loglevel command format: +         *  > volume log level <VOL> <XLATOR[*]> <LOGLEVEL> +         *  > volume log level colon-o posix WARNING +         *  > volume log level colon-o replicate* DEBUG +         *  > volume log level coon-o * TRACE +         */ + +        GF_ASSERT ((strncmp(words[0], "volume", 6) == 0)); +        GF_ASSERT ((strncmp(words[1], "log", 3) == 0)); +        GF_ASSERT ((strncmp(words[2], "level", 5) == 0)); + +        ret = glusterd_check_log_level(words[5]); +        if (ret == -1) { +                cli_out("invalid log level [%s] specified", words[4]); +                goto out; +        } + +        dict = dict_new (); +        if (!dict) +                goto out; + +        GF_ASSERT(words[3]); +        GF_ASSERT(words[4]); + +        ret = dict_set_str (dict, "volname", (char *)words[3]); +        if (ret) +                goto out; + +        ret = dict_set_str (dict, "xlator", (char *)words[4]); +        if (ret) +                goto out; + +        ret = dict_set_str (dict, "loglevel", (char *)words[5]); +        if (ret) +                goto out; + +        *options = dict; + + out: +        if (ret && dict) +                dict_destroy (dict); + +        return ret; +} + +int32_t  cli_cmd_log_locate_parse (const char **words, int wordcount, dict_t **options)  {          dict_t  *dict = NULL; diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index 673202440fc..7ca9ed4bb2f 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -1171,6 +1171,39 @@ out:          return ret;  } +int +cli_cmd_log_level_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 != 6) { +          cli_usage_out (word->pattern); +          parse_error = 1; +          goto out; +        } + +        proc = &cli_rpc_prog->proctable[GLUSTER_CLI_LOG_LEVEL]; + +        frame = create_frame (THIS, THIS->ctx->pool); +        if (!frame) +          goto out; + +        ret = cli_cmd_log_level_parse (words, wordcount, &dict); +        if (ret) +          goto out; + +        if (proc->fn) +          ret = proc->fn (frame, THIS, dict); + + out: +        return ret; +} +  struct cli_cmd volume_cmds[] = {          { "volume info [all|<VOLNAME>]",            cli_cmd_volume_info_cbk, @@ -1265,6 +1298,10 @@ struct cli_cmd volume_cmds[] = {             cli_cmd_volume_top_cbk,             "volume top operations"}, +        {"volume log level <VOLNAME> <XLATOR[*]> <LOGLEVEL>", +         cli_cmd_log_level_cbk, +         "log level for translator"}, +          { NULL, NULL, NULL }  }; diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 1a2c4ee94ed..83abb865bcb 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -2277,6 +2277,74 @@ out:          return ret;  } +static int +gf_cli3_1_log_level_cbk (struct rpc_req *req, struct iovec *iov, +                         int count, void *myframe) +{ +        gf1_cli_log_level_rsp rsp = {0,}; +        int                   ret = -1; + +        if (req->rpc_status == -1) +                goto out; + +        ret = gf_xdr_to_cli_log_level_rsp (*iov, &rsp); +        if (ret < 0) { +                gf_log ("cli", GF_LOG_ERROR, "log level response error"); +                goto out; +        } + +        gf_log ("cli", GF_LOG_DEBUG, "Received response to log level cmd"); + +        if (rsp.op_ret && strcmp (rsp.op_errstr, "")) +                cli_out (rsp.op_errstr); +        else +                cli_out ("log level set: %s", (rsp.op_ret) ? "unsuccessful" : +                         "successful"); + +        ret = rsp.op_ret; + + out: +        cli_cmd_broadcast_response (ret); +        return ret; +} + +int32_t +gf_cli3_1_log_level (call_frame_t *frame, xlator_t *this, +                     void *data) +{ +        gf1_cli_log_level_req  req  = {0,}; +        int                    ret  = 0; +        dict_t                *dict = NULL; + +        if (!frame || !this || !data) { +                ret = -1; +                goto out; +        } + +        dict = data; + +        ret = dict_get_str (dict, "volname", &req.volname); +        if (ret) +                goto out; + +        ret = dict_get_str (dict, "xlator", &req.xlator); +        if (ret) +                goto out; + +        ret = dict_get_str (dict, "loglevel", &req.loglevel); +        if (ret) +                goto out; + +        ret = cli_cmd_submit (&req, frame, cli_rpc_prog, +                              GLUSTER_CLI_LOG_LEVEL, NULL, +                              gf_xdr_from_cli_log_level_req, +                              this, gf_cli3_1_log_level_cbk); + + out: +        gf_log ("cli", GF_LOG_DEBUG, "Returning: %d", ret); +        return ret; +} +  int32_t  gf_cli3_1_log_locate (call_frame_t *frame, xlator_t *this, @@ -3429,6 +3497,7 @@ struct rpc_clnt_procedure gluster_cli_actors[GLUSTER_CLI_MAXVALUE] = {          [GLUSTER_CLI_PROFILE_VOLUME]   = {"PROFILE_VOLUME", gf_cli3_1_profile_volume},          [GLUSTER_CLI_QUOTA]            = {"QUOTA", gf_cli3_1_quota},          [GLUSTER_CLI_TOP_VOLUME]       = {"TOP_VOLUME", gf_cli3_1_top_volume}, +        [GLUSTER_CLI_LOG_LEVEL]        = {"VOLUME_LOGLEVEL", gf_cli3_1_log_level},          [GLUSTER_CLI_GETWD]            = {"GETWD", gf_cli3_1_getwd}  }; diff --git a/cli/src/cli.h b/cli/src/cli.h index 5d83f0fc1df..c81ae47e5cd 100644 --- a/cli/src/cli.h +++ b/cli/src/cli.h @@ -227,10 +227,15 @@ cli_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event,                  void *data);  void  cli_path_strip_trailing_slashes (char *path); +  int32_t  cli_cmd_volume_profile_parse (const char **words, int wordcount,                                dict_t **options);  int32_t  cli_cmd_volume_top_parse (const char **words, int wordcount,                                dict_t **options); + +int32_t +cli_cmd_log_level_parse (const char **words, int wordcount, +                         dict_t **options);  #endif /* __CLI_H__ */  | 
