diff options
author | Csaba Henk <csaba@gluster.com> | 2011-04-19 07:19:17 +0000 |
---|---|---|
committer | Anand Avati <avati@gluster.com> | 2011-04-21 00:39:50 -0700 |
commit | 0dd8c38d17e51c4b8bd1471854315e27c25cc615 (patch) | |
tree | 93a85fc17bf65ba58421afb30be2c9a73ed1c6b5 /cli/src | |
parent | 29ac0febecbca0700bb4b1e2335b8dace5ff452c (diff) |
geo-replication: revamp CONFIG command
Drop the config_type RPC req field, use just a "subop" key in the param 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
Diffstat (limited to 'cli/src')
-rw-r--r-- | cli/src/cli-cmd-parser.c | 27 | ||||
-rw-r--r-- | cli/src/cli-rpc-ops.c | 37 |
2 files changed, 26 insertions, 38 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 70a6327511e..4a395c849a9 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -1121,11 +1121,11 @@ int32_t cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options) { int32_t ret = -1; - int32_t config_type = 0; dict_t *dict = NULL; gf1_cli_gsync_set type = GF_GSYNC_OPTION_TYPE_NONE; char *append_str = NULL; size_t append_len = 0; + char *subop = NULL; int i = 0; GF_ASSERT (words); @@ -1192,34 +1192,32 @@ cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options) } if ((strcmp (words[2], "config")) == 0) { - type = GF_GSYNC_OPTION_TYPE_CONFIGURE; + type = GF_GSYNC_OPTION_TYPE_CONFIG; switch (wordcount) { case 5: - config_type = GF_GSYNC_OPTION_TYPE_CONFIG_GET_ALL; + subop = gf_strdup ("get-all"); break; case 6: if (words[5][0] == '!') { - config_type = GF_GSYNC_OPTION_TYPE_CONFIG_DEL; - i = 1; - } else { - config_type = GF_GSYNC_OPTION_TYPE_CONFIG_GET; - i = 0; - } + (words[5])++; + subop = gf_strdup ("del"); + } else + subop = gf_strdup ("get"); - ret = dict_set_str (dict, "op_name", ((char *)words[5]) + i); + ret = dict_set_str (dict, "op_name", ((char *)words[5])); if (ret < 0) goto out; break; default: - config_type = GF_GSYNC_OPTION_TYPE_CONFIG_SET; - if (wordcount < 7) { ret = -1; goto out; } + subop = gf_strdup ("set"); + ret = dict_set_str (dict, "op_name", (char *)words[5]); if (ret < 0) goto out; @@ -1246,9 +1244,10 @@ cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options) goto out; } - ret = dict_set_int32 (dict, "config_type", config_type); - if (ret < 0) + if (!subop || dict_set_dynstr (dict, "subop", subop) != 0) { + ret = -1; goto out; + } } else { ret = -1; goto out; diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index d6c507d2c9d..34033b1ea93 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -2586,7 +2586,7 @@ out: int -gf_cli3_1_gsync_get_command (gf1_cli_gsync_set_rsp rsp) +gf_cli3_1_gsync_config_command (gf1_cli_gsync_set_rsp rsp) { char cmd[PATH_MAX] = {0,}; int ret = -1; @@ -2597,28 +2597,21 @@ gf_cli3_1_gsync_get_command (gf1_cli_gsync_set_rsp rsp) if (!rsp.gsync_prefix || !rsp.master || !rsp.slave || !rsp.glusterd_workdir) return -1; - if (rsp.config_type == GF_GSYNC_OPTION_TYPE_CONFIG_GET) { - if (!rsp.op_name) - return -1; + if (strcmp (rsp.subop, "get") != 0 && strcmp (rsp.subop, "get-all") != 0) { + cli_out (GEOREP" config updated successfully"); + return 0; + } - snprintf (cmd, PATH_MAX, GSYNCD_PREFIX "/gsyncd -c %s/%s :%s %s" - " --config-get %s ", - rsp.glusterd_workdir, GSYNC_CONF, - rsp.master, rsp.slave, rsp.op_name); - ret = system (cmd); + snprintf (cmd, PATH_MAX, + GSYNCD_PREFIX"/gsyncd -c %s/"GSYNC_CONF" :%s %s --config-%s%s%s", + rsp.glusterd_workdir, rsp.master, rsp.slave, rsp.subop, + *rsp.op_name ? " " : "", rsp.op_name); + ret = system (cmd); /* * gf_log() failure from system() ? */ - } else if (rsp.config_type == GF_GSYNC_OPTION_TYPE_CONFIG_GET_ALL) { - snprintf (cmd, PATH_MAX, GSYNCD_PREFIX"/gsyncd -c %s/%s " - ":%s %s --config-get-all ", - rsp.glusterd_workdir, GSYNC_CONF, - rsp.master, rsp.slave); - - ret = system (cmd); - } - return 0; + return ret ? -1 : 0; } int @@ -2730,12 +2723,8 @@ gf_cli3_1_gsync_set_cbk (struct rpc_req *req, struct iovec *iov, " has been successful", rsp.master, rsp.slave); break; - case GF_GSYNC_OPTION_TYPE_CONFIGURE: - if(rsp.config_type==GF_GSYNC_OPTION_TYPE_CONFIG_GET_ALL - || rsp.config_type==GF_GSYNC_OPTION_TYPE_CONFIG_GET) - ret = gf_cli3_1_gsync_get_command (rsp); - else - cli_out (GEOREP" config updated successfully"); + case GF_GSYNC_OPTION_TYPE_CONFIG: + ret = gf_cli3_1_gsync_config_command (rsp); break; case GF_GSYNC_OPTION_TYPE_STATUS: |