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 /xlators/mgmt/glusterd/src/glusterd-ganesha.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 'xlators/mgmt/glusterd/src/glusterd-ganesha.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-ganesha.c | 159 |
1 files changed, 157 insertions, 2 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-ganesha.c b/xlators/mgmt/glusterd/src/glusterd-ganesha.c index 267e4b995cd..d8111afa423 100644 --- a/xlators/mgmt/glusterd/src/glusterd-ganesha.c +++ b/xlators/mgmt/glusterd/src/glusterd-ganesha.c @@ -24,7 +24,161 @@ #define MAXBUF 1024 #define DELIM "=\"" -/* Following 2 functions parses GANESHA_HA_CONF +int +glusterd_check_ganesha_cmd (char *key, char *value, char **errstr, dict_t *dict) +{ + int ret = 0; + gf_boolean_t b = _gf_false; + xlator_t *this = NULL; + + this = THIS; + GF_ASSERT (this); + GF_ASSERT (key); + GF_ASSERT (value); + + if ((strcmp (key, "ganesha.enable") == 0) || + (strcmp (key, "features.ganesha") == 0)) { + ret = gf_string2boolean (value, &b); + if (ret < 0) { + gf_log (this->name, GF_LOG_ERROR, "Failed to parse bool" + "string"); + goto out; + } + if ((strcmp (value, "on")) && (strcmp (value, "off"))) { + gf_log (this->name, GF_LOG_ERROR, "Invalid value" + "for volume set command. Use on/off only"); + ret = -1; + goto out; + } + ret = glusterd_handle_ganesha_op (dict, errstr, key, value); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, "Handling NFS-Ganesha op" + "failed."); + } + } +out: + return ret; +} + +int +glusterd_op_stage_set_ganesha (dict_t *dict, char **op_errstr) +{ + int ret = -1; + char *volname = NULL; + int exists = 0; + char *key = NULL; + char *value = NULL; + char str[100] = {0, } ; + int dict_count = 0; + int flags = 0; + char errstr[2048] = {0, } ; + glusterd_volinfo_t *volinfo = NULL; + glusterd_conf_t *priv = NULL; + xlator_t *this = NULL; + + GF_ASSERT (dict); + this = THIS; + GF_ASSERT (this); + priv = this->private; + GF_ASSERT (priv); + + ret = dict_get_str (dict, "key", &key); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, + "invalid key"); + goto out; + } + + ret = dict_get_str (dict, "value", &value); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, + "invalid key,value pair in 'global vol set'"); + goto out; + } +out: + + if (ret) { + if (!(*op_errstr)) { + *op_errstr = gf_strdup ("Error, Validation Failed"); + gf_log (this->name, GF_LOG_DEBUG, + "Error, Cannot Validate option :%s %s", + key, value); + } else { + gf_log (this->name, GF_LOG_DEBUG, + "Error, Cannot Validate option"); + } + } + return ret; +} + +int +glusterd_op_set_ganesha (dict_t *dict, char **errstr) +{ + int ret = 0; + int flags = 0; + glusterd_volinfo_t *volinfo = NULL; + char *volname = NULL; + xlator_t *this = NULL; + glusterd_conf_t *priv = NULL; + char *key = NULL; + char *value = NULL; + char str[50] = {0, }; + int32_t dict_count = 0; + dict_t *vol_opts = NULL; + int count = 0; + + this = THIS; + GF_ASSERT (this); + GF_ASSERT (dict); + + priv = this->private; + GF_ASSERT (priv); + + + ret = dict_get_str (dict, "key", &key); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, + "Couldn't get key in global option set"); + goto out; + } + + ret = dict_get_str (dict, "value", &value); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, + "Couldn't get value in global option set"); + goto out; + } + + ret = glusterd_handle_ganesha_op (dict, errstr, key, value); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, + "Initial NFS-Ganesha set up failed"); + ret = -1; + goto out; + } + ret = dict_set_str(priv->opts, "features.ganesha", value); + if (ret) { + gf_log (this->name, GF_LOG_WARNING, "Failed to set" + " features.ganesha in dict."); + goto out; + } + + /* To do : Lock the global options file before writing */ + /* into this file. Bug ID : 1200254 */ + + ret = glusterd_store_options (this, priv->opts); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, + "Failed to store options"); + goto out; + } + +out: + gf_log (this->name, GF_LOG_DEBUG, "returning %d", ret); + return ret; +} + +/* Following 2 functions parse GANESHA_HA_CONF * The sample file looks like below, * HA_NAME="ganesha-ha-360" * HA_VOL_NAME="ha-state" @@ -181,6 +335,7 @@ ganesha_manage_export (dict_t *dict, char *value, char **op_errstr) FMTSTR_CHECK_VOL_EXISTS, volname); goto out; } + /* Todo : check if global option is enabled, proceed only then */ /* Create the export file only when ganesha.enable "on" is executed */ if (strcmp (value, "on") == 0) { @@ -253,7 +408,7 @@ stop_ganesha (char **op_errstr) if (check_host_list ()) { runinit (&runner); - runner_add_args (&runner, "service nfs-ganesha", "stop", NULL); + runner_add_args (&runner, "service", " nfs-ganesha", "stop", NULL); ret = runner_run (&runner); } out: |