diff options
author | Meghana Madhusudhan <mmadhusu@redhat.com> | 2015-02-02 16:23:22 +0530 |
---|---|---|
committer | Kaleb KEITHLEY <kkeithle@redhat.com> | 2015-03-18 04:33:13 -0700 |
commit | 38ccaaf9d1a93c4fc6d733ee3bd5c73e5457bdab (patch) | |
tree | 8856e8a6a869d6a0f1444c74e6bd05b08d950940 /cli/src/cli-cmd-parser.c | |
parent | 8a9c909702f4f6836bd1d0c791a7b1ae79d4ba15 (diff) |
CLI : GLobal option for NFS-Ganesha
A new global CLI option has been introduced for NFS-Ganesha.
gluster features.ganesha enable/disable.
This option is persistent and shall be inherited
by new volumes created after this option is set.
gluster features.ganesha enable
It carries out the following functions:
1. Disables gluster-nfs across the cluster
2. Starts NFS-Ganesha server on a subset of nodes and exports '/'.
3. Creates the HA cluster for NFS-Ganesha.
4. Writes the option into the global config file.
gluster features.ganesha disable
1. Stops NFS-Ganesha server.
2. Tears down the HA cluster for NFS-Ganesha
With this change the older volume set
options with keys "nfs-ganesha.host"
and "nfs-ganesha.enable" will no longer
be supported. This commit has only has the
CLI related changes. Another patch will
be submitted to support this feature entirely.
Change-Id: Ie4b66a16c23b33b795738654b9a68f8e2c34efe3
BUG: 1188184
Signed-off-by: Meghana Madhusudhan <mmadhusu@redhat.com>
Reviewed-on: http://review.gluster.org/9538
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Diffstat (limited to 'cli/src/cli-cmd-parser.c')
-rw-r--r-- | cli/src/cli-cmd-parser.c | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index aa512738784..c7fdafb32b6 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -754,6 +754,99 @@ out: return ret; } +/* Parsing global option for NFS-Ganesha config + * gluster features.ganesha enable/disable */ + +int32_t +cli_cmd_ganesha_parse (struct cli_state *state, + const char **words, int wordcount, + dict_t **options, char **op_errstr) +{ + dict_t *dict = NULL; + int ret = -1; + int flags = 0; + char *key = NULL; + char *value = NULL; + int i = 0; + char *w = NULL; + char *opwords[] = { "enable", "disable" }; + const char *question = NULL; + gf_answer_t answer = GF_ANSWER_NO; + + + GF_ASSERT (words); + GF_ASSERT (options); + + dict = dict_new (); + + if (!dict) + goto out; + + if (wordcount != 2) + goto out; + + key = (char *) words[0]; + value = (char *) words[1]; + + if (!key || !value) { + cli_out ("Usage : features.ganesha <enable/disable>"); + ret = -1; + goto out; + } + + ret = gf_strip_whitespace (value, strlen (value)); + if (ret == -1) + goto out; + + if (strcmp (key, "features.ganesha")) { + gf_asprintf (op_errstr, "Global option: error: ' %s '" + "is not a valid global option.", key); + ret = -1; + goto out; + } + + w = str_getunamb (value, opwords); + if (!w) { + cli_out ("Invalid global option \n" + "Usage : features.ganesha <enable/disable>"); + ret = -1; + goto out; + } + + question = "Enabling NFS-Ganesha requires Gluster-NFS to be" + "disabled across the trusted pool. Do you " + "still want to continue?"; + + if (strcmp (value, "enable") == 0) { + answer = cli_cmd_get_confirmation (state, question); + if (GF_ANSWER_NO == answer) { + gf_log ("cli", GF_LOG_ERROR, "Global operation " + "cancelled, exiting"); + ret = -1; + goto out; + } + } + + ret = dict_set_str (dict, "key", key); + if (ret) { + gf_log (THIS->name, GF_LOG_ERROR, "dict set on key failed"); + goto out; + } + + ret = dict_set_str (dict, "value", value); + if (ret) { + gf_log (THIS->name, GF_LOG_ERROR, "dict set on value failed"); + goto out; + } + + *options = dict; +out: + if (ret) + dict_unref (dict); + + return ret; +} + int32_t cli_cmd_quota_parse (const char **words, int wordcount, dict_t **options) { |