summaryrefslogtreecommitdiffstats
path: root/cli/src/cli-cmd-parser.c
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/src/cli-cmd-parser.c
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/src/cli-cmd-parser.c')
-rw-r--r--cli/src/cli-cmd-parser.c96
1 files changed, 96 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;
+}
+