summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorMohammed Junaid Ahmed <junaid@gluster.com>2011-02-10 05:29:34 +0000
committerAnand V. Avati <avati@dev.gluster.com>2011-02-10 22:18:06 -0800
commit2e81c881f036d90323fd07d7df07d881723d7a28 (patch)
tree261c45c9faf90f70a8140994adcc02b9cd881220 /cli
parent08ca1d3c7801d22f1de452f098b0a5df251ca5e7 (diff)
gsync: cli support for gsyncd.
Signed-off-by: Junaid <junaid@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 1570 (geosync related changes) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1570
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-cmd-parser.c96
-rw-r--r--cli/src/cli-cmd-volume.c45
-rw-r--r--cli/src/cli.h3
-rw-r--r--cli/src/cli3_1-cops.c71
4 files changed, 215 insertions, 0 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index 7c02e1f0562..6fa1f80bdfe 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -1011,3 +1011,99 @@ out:
return ret;
}
+
+int32_t
+cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options)
+{
+ int32_t ret = 0;
+ int32_t config_type = 0;
+ dict_t *dict = NULL;
+ gf1_cli_gsync_set type = GF_GSYNC_OPTION_TYPE_NONE;
+
+ GF_ASSERT (words);
+ GF_ASSERT (options);
+
+ GF_ASSERT ((strcmp (words[0], "volume")) == 0);
+ GF_ASSERT ((strcmp (words[1], "gsync")) == 0);
+
+ dict = dict_new ();
+ if (!dict)
+ goto out;
+
+ if (wordcount < 5)
+ goto out;
+
+ ret = dict_set_str (dict, "master", (char *)words[3]);
+ if (ret < 0)
+ goto out;
+
+ ret = dict_set_str (dict, "slave", (char *)words[4]);
+ if (ret < 0)
+ goto out;
+
+ if ((strcmp (words[2], "start")) == 0) {
+ type = GF_GSYNC_OPTION_TYPE_START;
+
+ goto set_type;
+ }
+
+ if ((strcmp (words[2], "stop")) == 0) {
+ type = GF_GSYNC_OPTION_TYPE_STOP;
+
+ goto set_type;
+ }
+
+ if ((strcmp (words[2], "configure")) == 0) {
+ type = GF_GSYNC_OPTION_TYPE_CONFIGURE;
+
+ if (strcmp (words [5], "config-set") == 0) {
+ config_type = GF_GSYNC_OPTION_TYPE_CONFIG_SET;
+
+ ret = dict_set_str (dict, "op_name", (char *)words[6]);
+ if (ret < 0)
+ goto out;
+
+ ret = dict_set_str (dict, "op_value", (char *)words[7]);
+ if (ret < 0)
+ goto out;
+ }
+
+ if ((strcmp (words [5], "config-del")) == 0) {
+ config_type = GF_GSYNC_OPTION_TYPE_CONFIG_DEL;
+
+ ret = dict_set_str (dict, "op_name", (char *)words[6]);
+ if (ret < 0)
+ goto out;
+ }
+
+ if ((strcmp (words [5], "config-get")) == 0) {
+ config_type = GF_GSYNC_OPTION_TYPE_CONFIG_GET;
+
+ ret = dict_set_str (dict, "op_name", (char *)words[6]);
+ if (ret < 0)
+ goto out;
+ }
+
+ if ((strcmp (words [5], "config-get-all")) == 0) {
+ config_type = GF_GSYNC_OPTION_TYPE_CONFIG_GET_ALL;
+ }
+
+ ret = dict_set_int32 (dict, "config_type", config_type);
+ if (ret < 0)
+ goto out;
+ }
+
+set_type:
+ ret = dict_set_int32 (dict, "type", type);
+ if (ret < 0)
+ goto out;
+
+ *options = dict;
+out:
+ if (ret)
+ if (dict)
+ dict_destroy (dict);
+
+ return ret;
+}
+
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index fd2a7afe07e..7ecfde2e03a 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -879,6 +879,47 @@ out:
return ret;
}
+int
+cli_cmd_volume_gsync_set_cbk (struct cli_state *state, struct cli_cmd_word *word,
+ const char **words, int wordcount)
+{
+ int ret = 0;
+ int parse_err = 0;
+ dict_t *options = NULL;
+ rpc_clnt_procedure_t *proc = NULL;
+ call_frame_t *frame = NULL;
+
+ proc = &cli_rpc_prog->proctable [GF1_CLI_GSYNC_SET];
+ if (proc == NULL) {
+ ret = -1;
+ goto out;
+ }
+
+ frame = create_frame (THIS, THIS->ctx->pool);
+ if (frame == NULL) {
+ ret = -1;
+ goto out;
+ }
+
+ ret = cli_cmd_gsync_set_parse (words, wordcount, &options);
+ if (ret) {
+ cli_usage_out (word->pattern);
+ parse_err = 1;
+ goto out;
+ }
+
+ if (proc->fn)
+ ret = proc->fn (frame, THIS, options);
+
+out:
+ if (options)
+ dict_unref (options);
+
+ if (ret && parse_err == 0)
+ cli_out ("Gsync command failed");
+
+ return ret;
+}
struct cli_cmd volume_cmds[] = {
{ "volume info [all|<VOLNAME>]",
@@ -953,6 +994,10 @@ struct cli_cmd volume_cmds[] = {
cli_cmd_volume_reset_cbk,
"reset all the reconfigured options"},
+ {"volume gsync <start|stop|configure> <MASTER> <SLAVE> [options]",
+ cli_cmd_volume_gsync_set_cbk,
+ "Geo-sync operations"},
+
{ NULL, NULL, NULL }
};
diff --git a/cli/src/cli.h b/cli/src/cli.h
index c0fb5a7e5a4..77bc249d920 100644
--- a/cli/src/cli.h
+++ b/cli/src/cli.h
@@ -176,6 +176,9 @@ int32_t
cli_cmd_volume_reset_parse (const char **words, int wordcount, dict_t **opt);
int32_t
+cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **opt);
+
+int32_t
cli_cmd_volume_set_parse (const char **words, int wordcount,
dict_t **options);
diff --git a/cli/src/cli3_1-cops.c b/cli/src/cli3_1-cops.c
index a9881502036..612b04724b0 100644
--- a/cli/src/cli3_1-cops.c
+++ b/cli/src/cli3_1-cops.c
@@ -2396,6 +2396,76 @@ out:
return ret;
}
+int
+gf_cli3_1_gsync_set_cbk (struct rpc_req *req, struct iovec *iov,
+ int count, void *myframe)
+{
+ int ret = 0;
+ gf1_cli_gsync_set_rsp rsp = {0, };
+
+ if (req->rpc_status == -1) {
+ ret = -1;
+ goto out;
+ }
+
+ ret = gf_xdr_to_cli_gsync_set_rsp (*iov, &rsp);
+ if (ret < 0) {
+ gf_log ("", GF_LOG_ERROR,
+ "Unable to get response structure");
+ goto out;
+ }
+
+ if (rsp.op_errstr)
+ cli_out ("%s", rsp.op_errstr);
+ else if (rsp.op_ret)
+ cli_out ("command unsuccessful");
+ else
+ cli_out ("command executed successfully");
+
+out:
+ ret = rsp.op_ret;
+
+ cli_cmd_broadcast_response (ret);
+
+ return ret;
+}
+
+int32_t
+gf_cli3_1_gsync_set (call_frame_t *frame, xlator_t *this,
+ void *data)
+{
+ int ret = 0;
+ dict_t *dict = NULL;
+ gf1_cli_gsync_set_req req;
+
+ if (!frame || !this || !data) {
+ ret = -1;
+ goto out;
+ }
+
+ dict = data;
+
+ ret = dict_allocate_and_serialize (dict,
+ &req.dict.dict_val,
+ (size_t *) &req.dict.dict_len);
+ if (ret < 0) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "failed to serialize the data");
+
+ goto out;
+ }
+
+ ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
+ GD_MGMT_CLI_GSYNC_SET, NULL,
+ gf_xdr_from_cli_gsync_set_req,
+ this, gf_cli3_1_gsync_set_cbk);
+
+out:
+ return ret;
+}
+
+
+
struct rpc_clnt_procedure gluster3_1_cli_actors[GF1_CLI_MAXVALUE] = {
[GF1_CLI_NULL] = {"NULL", NULL },
[GF1_CLI_PROBE] = { "PROBE_QUERY", gf_cli3_1_probe},
@@ -2420,6 +2490,7 @@ struct rpc_clnt_procedure gluster3_1_cli_actors[GF1_CLI_MAXVALUE] = {
[GF1_CLI_PMAP_PORTBYBRICK] = {"PMAP PORTBYBRICK", gf_cli3_1_pmap_b2p},
[GF1_CLI_SYNC_VOLUME] = {"SYNC_VOLUME", gf_cli3_1_sync_volume},
[GF1_CLI_RESET_VOLUME] = {"RESET_VOLUME", gf_cli3_1_reset_volume},
+ [GF1_CLI_GSYNC_SET] = {"GSYNC_SET", gf_cli3_1_gsync_set},
[GF1_CLI_FSM_LOG] = {"FSM_LOG", gf_cli3_1_fsm_log}
};