diff options
author | Csaba Henk <csaba@gluster.com> | 2011-04-29 06:24:40 +0000 |
---|---|---|
committer | Anand Avati <avati@gluster.com> | 2011-05-09 13:26:48 -0700 |
commit | 97fdc05ab86ca2af992c42b09ed40413be2ef0d8 (patch) | |
tree | 6ad6a905f34ec7db443e97031ffa62c3f952eaf8 | |
parent | 6dd0282fbfa14eb5a6ae3df1083ef1eea443ea20 (diff) |
glusterd / cli / rpc: move geo-replication reply parameters into dict
Signed-off-by: Csaba Henk <csaba@gluster.com>
Signed-off-by: Anand Avati <avati@gluster.com>
BUG: 2785 (gsyncd logs on slave side go to /dev/null)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2785
-rw-r--r-- | cli/src/cli-rpc-ops.c | 61 | ||||
-rw-r--r-- | rpc/xdr/src/cli1-xdr.c | 16 | ||||
-rw-r--r-- | rpc/xdr/src/cli1-xdr.h | 12 | ||||
-rw-r--r-- | rpc/xdr/src/cli1-xdr.x | 8 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-rpc-ops.c | 32 |
5 files changed, 46 insertions, 83 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 794eab0178c..1a2c4ee94ed 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -2586,33 +2586,38 @@ out: int -gf_cli3_1_gsync_config_command (gf1_cli_gsync_set_rsp rsp) +gf_cli3_1_gsync_config_command (dict_t *dict) { char cmd[PATH_MAX] = {0,}; - int ret = -1; + char *subop = NULL; + char *gwd = NULL; + char *slave = NULL; + char *master = NULL; + char *op_name = NULL; - if (rsp.op_ret < 0) - return 0; - - if (!rsp.gsync_prefix || !rsp.master || !rsp.slave || !rsp.glusterd_workdir) + if (dict_get_str (dict, "subop", &subop) != 0) return -1; - if (strcmp (rsp.subop, "get") != 0 && strcmp (rsp.subop, "get-all") != 0) { + if (strcmp (subop, "get") != 0 && strcmp (subop, "get-all") != 0) { cli_out (GEOREP" config updated successfully"); return 0; } + if (dict_get_str (dict, "glusterd_workdir", &gwd) != 0 || + dict_get_str (dict, "slave", &slave) != 0) + return -1; + + if (dict_get_str (dict, "master", &master) != 0) + master = ""; + if (dict_get_str (dict, "op_name", &op_name) != 0) + op_name = ""; + snprintf (cmd, PATH_MAX, GSYNCD_PREFIX"/gsyncd -c %s/"GSYNC_CONF" %s%s %s --config-%s%s%s", - rsp.glusterd_workdir, - *rsp.master ? ":" : "", rsp.master, rsp.slave, rsp.subop, - *rsp.op_name ? " " : "", rsp.op_name); - ret = system (cmd); - /* - * gf_log() failure from system() ? - */ - - return ret ? -1 : 0; + gwd, *master ? ":" : "", master, slave, + subop, *op_name ? " " : "", op_name); + + return system (cmd) ? -1 : 0; } int @@ -2679,6 +2684,8 @@ gf_cli3_1_gsync_set_cbk (struct rpc_req *req, struct iovec *iov, int ret = 0; gf1_cli_gsync_set_rsp rsp = {0, }; dict_t *dict = NULL; + char *master = NULL; + char *slave = NULL; if (req->rpc_status == -1) { ret = -1; @@ -2699,9 +2706,7 @@ gf_cli3_1_gsync_set_cbk (struct rpc_req *req, struct iovec *iov, goto out; } - ret = dict_unserialize (rsp.status_dict.status_dict_val, - rsp.status_dict.status_dict_len, - &dict); + ret = dict_unserialize (rsp.dict.dict_val, rsp.dict.dict_len, &dict); if (ret) goto out; @@ -2715,17 +2720,21 @@ gf_cli3_1_gsync_set_cbk (struct rpc_req *req, struct iovec *iov, switch (rsp.type) { case GF_GSYNC_OPTION_TYPE_START: - cli_out ("Starting " GEOREP " session between %s & %s" - " has been successful", rsp.master, rsp.slave); - break; - case GF_GSYNC_OPTION_TYPE_STOP: - cli_out ("Stopping " GEOREP " session between %s & %s" - " has been successful", rsp.master, rsp.slave); + if (dict_get_str (dict, "master", &master) != 0) + master = "???"; + if (dict_get_str (dict, "slave", &slave) != 0) + slave = "???"; + + cli_out ("%s " GEOREP " session between %s & %s" + " has been successful", + rsp.type == GF_GSYNC_OPTION_TYPE_START ? + "Starting" : "Stopping", + master, slave); break; case GF_GSYNC_OPTION_TYPE_CONFIG: - ret = gf_cli3_1_gsync_config_command (rsp); + ret = gf_cli3_1_gsync_config_command (dict); break; case GF_GSYNC_OPTION_TYPE_STATUS: diff --git a/rpc/xdr/src/cli1-xdr.c b/rpc/xdr/src/cli1-xdr.c index e0a1e1075b1..e525bb755c5 100644 --- a/rpc/xdr/src/cli1-xdr.c +++ b/rpc/xdr/src/cli1-xdr.c @@ -749,20 +749,8 @@ xdr_gf1_cli_gsync_set_rsp (XDR *xdrs, gf1_cli_gsync_set_rsp *objp) return FALSE; if (!xdr_int (xdrs, &objp->type)) return FALSE; - if (!xdr_string (xdrs, &objp->op_name, ~0)) - return FALSE; - if (!xdr_string (xdrs, &objp->subop, ~0)) - return FALSE; - if (!xdr_string (xdrs, &objp->master, ~0)) - return FALSE; - if (!xdr_string (xdrs, &objp->slave, ~0)) - return FALSE; - if (!xdr_string (xdrs, &objp->gsync_prefix, ~0)) - return FALSE; - if (!xdr_string (xdrs, &objp->glusterd_workdir, ~0)) - return FALSE; - if (!xdr_bytes (xdrs, (char **)&objp->status_dict.status_dict_val, - (u_int *) &objp->status_dict.status_dict_len, ~0)) + if (!xdr_bytes (xdrs, (char **)&objp->dict.dict_val, + (u_int *) &objp->dict.dict_len, ~0)) return FALSE; return TRUE; diff --git a/rpc/xdr/src/cli1-xdr.h b/rpc/xdr/src/cli1-xdr.h index 5b6bfd8f1fe..42e5cbff860 100644 --- a/rpc/xdr/src/cli1-xdr.h +++ b/rpc/xdr/src/cli1-xdr.h @@ -474,16 +474,10 @@ struct gf1_cli_gsync_set_rsp { int op_errno; char *op_errstr; int type; - char *op_name; - char *subop; - char *master; - char *slave; - char *gsync_prefix; - char *glusterd_workdir; struct { - u_int status_dict_len; - char *status_dict_val; - } status_dict; + u_int dict_len; + char *dict_val; + } dict; }; typedef struct gf1_cli_gsync_set_rsp gf1_cli_gsync_set_rsp; diff --git a/rpc/xdr/src/cli1-xdr.x b/rpc/xdr/src/cli1-xdr.x index 154a2c8e3e4..4b15dcd2957 100644 --- a/rpc/xdr/src/cli1-xdr.x +++ b/rpc/xdr/src/cli1-xdr.x @@ -338,13 +338,7 @@ struct gf1_cli_gsync_set_rsp { int op_errno; string op_errstr<>; int type; - string op_name<>; - string subop<>; - string master<>; - string slave<>; - string gsync_prefix<>; - string glusterd_workdir<>; - opaque status_dict<>; + opaque dict<>; }; struct gf1_cli_stats_volume_req { diff --git a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c index 65ccec4d449..bee892873a2 100644 --- a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c @@ -259,22 +259,12 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret, { int type = 0; char *str = NULL; - char *master = NULL; - char *slave = NULL; - char *op_name = NULL; - char *subop = NULL; gf1_cli_gsync_set_rsp rsp = {0,}; ctx = op_ctx; rsp.op_ret = op_ret; rsp.op_errno = op_errno; rsp.op_errstr = ""; - rsp.op_name = ""; - rsp.subop = ""; - rsp.master = ""; - rsp.slave = ""; - rsp.glusterd_workdir = conf->workdir; - rsp.gsync_prefix = GSYNCD_PREFIX; if (ctx) { ret = dict_get_str (ctx, "errstr", &str); if (ret == 0) @@ -282,27 +272,15 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret, ret = dict_get_int32 (ctx, "type", &type); if (ret == 0) rsp.type = type; - ret = dict_get_str (ctx, "master", &master); - if (ret == 0) - rsp.master = master; - - ret = dict_get_str (ctx, "slave", &slave); - if (ret == 0) - rsp.slave = slave; - - if (type == GF_GSYNC_OPTION_TYPE_CONFIG) { - if (dict_get_str (ctx, "op_name", &op_name) == 0) - rsp.op_name = op_name; - if (dict_get_str (ctx, "subop", &subop) == 0) - rsp.subop = subop; - } + ret = dict_set_str (ctx, "glusterd_workdir", conf->workdir); + /* swallow error here, that will be re-triggered in cli */ ret = dict_allocate_and_serialize (ctx, - &rsp.status_dict.status_dict_val, - (size_t*)&rsp.status_dict.status_dict_len); + &rsp.dict.dict_val, + (size_t*)&rsp.dict.dict_len); if (ret == 0) - free_ptr = rsp.status_dict.status_dict_val; + free_ptr = rsp.dict.dict_val; } if (op_errstr) |