From 2cd8411a0278f98ed820aad3e482de079d0540c0 Mon Sep 17 00:00:00 2001 From: Venky Shankar Date: Mon, 25 Apr 2011 03:10:01 +0000 Subject: cli log level command and per translator log level Signed-off-by: Venky Shankar Signed-off-by: Anand Avati BUG: 2714 (implement cli log level command) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2714 --- cli/src/cli-rpc-ops.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) (limited to 'cli/src/cli-rpc-ops.c') 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} }; -- cgit