summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorCsaba Henk <csaba@gluster.com>2011-04-13 01:46:10 +0000
committerAnand Avati <avati@gluster.com>2011-04-13 04:43:27 -0700
commit6608d60aa6ba733fbdc612e27499524b28adadbf (patch)
tree3df756c85aaa32bec834a05a5993db53a22dc94a /cli
parentebd99e25bf811ab14540f74dd50b445c217e7ee0 (diff)
cli: simplfy gsysnc configuration command
New syntax is volume gsync config <master> <slave> [[!]opt [val]] In details: - instead of "volume gsyncd configure M S config-get-all" : "volume gsyncd config M S" - instead of "volume gsyncd configure M S config-get O" : "volume gsyncd config M S O" - instead of "volume gsyncd configure M S config-del O" : "volume gsyncd config M S !O" - instead of "volume gsyncd configure M S config-set O V" : "volume gsyncd config M S O V" Signed-off-by: Csaba Henk <csaba@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 2738 ("volume gsync configure <master> <slave> config-<subop> ..." is overly verbose) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2738
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-cmd-parser.c49
-rw-r--r--cli/src/cli-cmd-volume.c2
2 files changed, 24 insertions, 27 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index ca4c8d315ce..1cfba3561fc 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -1161,24 +1161,41 @@ cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options)
goto set_type;
}
- if ((strcmp (words[2], "configure")) == 0) {
+ if ((strcmp (words[2], "config")) == 0) {
type = GF_GSYNC_OPTION_TYPE_CONFIGURE;
- if (strcmp (words [5], "config-set") == 0) {
+ switch (wordcount) {
+ case 5:
+ config_type = GF_GSYNC_OPTION_TYPE_CONFIG_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;
+ }
+
+ ret = dict_set_str (dict, "op_name", ((char *)words[5]) + i);
+ if (ret < 0)
+ goto out;
+ break;
+ default:
config_type = GF_GSYNC_OPTION_TYPE_CONFIG_SET;
- if (wordcount < 8) {
+ if (wordcount < 7) {
ret = -1;
goto out;
}
- ret = dict_set_str (dict, "op_name", (char *)words[6]);
+ ret = dict_set_str (dict, "op_name", (char *)words[5]);
if (ret < 0)
goto out;
/*XXX hack to get around the fact, where parsing of
* args is done based on spaces */
- for (i = 7; i < wordcount; i++)
+ for (i = 6; i < wordcount; i++)
append_len += (strlen (words[i]) + 1);
append_len++; /* trailing strcat will add two bytes, make space for that */
@@ -1188,7 +1205,7 @@ cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options)
goto out;
}
- for (i = 7; i< wordcount; i++) {
+ for (i = 6; i< wordcount; i++) {
strcat (append_str, words[i]);
strcat (append_str, " ");
}
@@ -1199,26 +1216,6 @@ cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options)
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;
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index 1735c387346..41533cf5c9f 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -1165,7 +1165,7 @@ struct cli_cmd volume_cmds[] = {
"reset all the reconfigured options"},
#if (SYNCDAEMON_COMPILE)
- {"volume gsync <start|stop|configure> <MASTER> <SLAVE> [options]",
+ {"volume gsync <start|stop|config> <MASTER> <SLAVE> [options]",
cli_cmd_volume_gsync_set_cbk,
"Geo-sync operations"},
#endif