diff options
author | Gaurav <gaurav@gluster.com> | 2011-03-23 00:50:17 +0000 |
---|---|---|
committer | Vijay Bellur <vijay@dev.gluster.com> | 2011-03-23 04:55:29 -0700 |
commit | 9bd4f25b6b0ea8103324b685fcc21525a29849a8 (patch) | |
tree | 7b0e0b875934521dea0c6fdd3412ac61972a527e /xlators/protocol | |
parent | 6f6c817314a2a867be996c2ad6d9a1337617ded4 (diff) |
CLI : Validate options farmework.
Signed-off-by: Gaurav <gaurav@gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>
BUG: 2064 (NFS options are removed upon glusterd restart)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2064
Diffstat (limited to 'xlators/protocol')
-rw-r--r-- | xlators/protocol/client/src/client.c | 79 | ||||
-rw-r--r-- | xlators/protocol/server/src/server.c | 64 |
2 files changed, 33 insertions, 110 deletions
diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c index 3082656f4d5..22394f59fcd 100644 --- a/xlators/protocol/client/src/client.c +++ b/xlators/protocol/client/src/client.c @@ -2076,72 +2076,31 @@ out: } int -validate_options (xlator_t *this, dict_t *options, char **op_errstr) +validate_options (xlator_t *this, char **op_errstr) { - int ret = 0; - int timeout_ret=0; - int ping_timeout; - int frame_timeout; - - - timeout_ret = dict_get_int32 (options, "frame-timeout", - &frame_timeout); - if (timeout_ret == 0) { - if (frame_timeout < 5 ) { - gf_log (this->name, GF_LOG_WARNING, "validation of " - "'option frame-timeout %d failed, min value" - " can be 5", frame_timeout); - *op_errstr = gf_strdup ("Error, Min Value 5"); - ret = -1; - goto out; - } - - if (frame_timeout > 86400 ) { - gf_log (this->name, GF_LOG_WARNING, "reconfiguration of" - " 'option frame-timeout %d failed , max value " - "can be 86400", frame_timeout ); - *op_errstr = gf_strdup ("Error, Max Value 86400"); - ret = -1; - goto out; - } - - - gf_log (this->name, GF_LOG_DEBUG, - "validation otion frame-timeout to %d", - frame_timeout); + int ret = 0; + volume_opt_list_t *vol_opt = NULL; + volume_opt_list_t *tmp; + if (!this) { + gf_log (this->name, GF_LOG_DEBUG, "'this' not a valid ptr"); + ret =-1; + goto out; } - timeout_ret = dict_get_int32 (options, "ping-timeout", - &ping_timeout); - if (timeout_ret == 0) { - - if (ping_timeout < 5 ) { - gf_log (this->name, GF_LOG_WARNING, "Reconfiguration" - " 'option ping-timeout %d failed , Min value" - " can be 5", ping_timeout); - *op_errstr = gf_strdup ("Error, Min Value 5"); - ret = -1; - goto out; - } - - if (ping_timeout > 1013 ) { - gf_log (this->name, GF_LOG_WARNING, "Reconfiguration" - " 'option frame-timeout %d failed , Max value" - " can be 1013,", frame_timeout); - *op_errstr = gf_strdup ("Error, Max Value 1013"); - ret = -1; - goto out; - } - - gf_log (this->name, GF_LOG_DEBUG, "Validated " - "'option ping-timeout' to %d", ping_timeout); + if (list_empty (&this->volume_options)) + goto out; + vol_opt = list_entry (this->volume_options.next, + volume_opt_list_t, list); + list_for_each_entry_safe (vol_opt, tmp, &this->volume_options, list) { + ret = validate_xlator_volume_options_attacherr (this, + vol_opt->given_opt, + op_errstr); } - ret = 0; - out: + return ret; } @@ -2169,7 +2128,6 @@ reconfigure (xlator_t *this, dict_t *options) "'option frame-timeout %d failed , Min value" " can be 5, Defaulting to old value (%d)" , frame_timeout, conf->rpc_conf.rpc_timeout); - ret = -1; goto out; } @@ -2178,7 +2136,6 @@ reconfigure (xlator_t *this, dict_t *options) "'option frame-timeout %d failed , Max value" "can be 3600, Defaulting to old value (%d)" , frame_timeout, conf->rpc_conf.rpc_timeout); - ret = -1; goto out; } @@ -2201,7 +2158,6 @@ reconfigure (xlator_t *this, dict_t *options) "'option ping-timeout %d failed , Min value" " can be 5, Defaulting to old value (%d)" , ping_timeout, conf->opt.ping_timeout); - ret = -1; goto out; } @@ -2210,7 +2166,6 @@ reconfigure (xlator_t *this, dict_t *options) "'option ping-timeout %d failed , Max value" "can be 1013, Defaulting to old value (%d)" , ping_timeout, conf->opt.ping_timeout); - ret = -1; goto out; } diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c index c1bcf61e431..73612719e45 100644 --- a/xlators/protocol/server/src/server.c +++ b/xlators/protocol/server/src/server.c @@ -472,66 +472,34 @@ out: } int -validate_options (xlator_t *this, dict_t *options, char **op_errstr) +validate_options ( xlator_t *this, char **op_errstr) { - int inode_lru_limit = 0; - char errstr[1024] = {0, }; - dict_t *auth_modules = NULL; - int ret = 0; - data_t *data; - gf_boolean_t trace; + int ret = 0; + volume_opt_list_t *vol_opt = NULL; + volume_opt_list_t *tmp; - if (dict_get_int32 ( options, "inode-lru-limit", &inode_lru_limit) == 0){ - if (!(inode_lru_limit < (1 * GF_UNIT_MB) && - inode_lru_limit >1 )) { - gf_log (this->name, GF_LOG_INFO, "Validate inode-lru" - "-limit %d, was WRONG", inode_lru_limit); - snprintf (errstr,1024, "Error, Greater than max value %d " - ,inode_lru_limit); - - *op_errstr = gf_strdup (errstr); - ret = -1; - goto out; - } - } - - data = dict_get (options, "trace"); - if (data) { - ret = gf_string2boolean (data->data, &trace); - if (ret != 0) { - gf_log (this->name, GF_LOG_WARNING, - "'trace' takes on only boolean values. " - "Neglecting option"); - snprintf (errstr,1024, "Error, trace takes only boolean" - "values"); - *op_errstr = gf_strdup (errstr); - ret = -1; - goto out; - } - } - - auth_modules = dict_new (); - if (!auth_modules) { - ret = -1; + if (!this) { + gf_log (this->name, GF_LOG_DEBUG, "'this' not a valid ptr"); + ret =-1; goto out; } - dict_foreach (options, get_auth_types, auth_modules); - ret = validate_auth_options (this, options); - if (ret == -1) { - /* logging already done in validate_auth_options function. */ - snprintf (errstr,1024, "authentication values are incorrect"); - *op_errstr = gf_strdup (errstr); + if (list_empty (&this->volume_options)) goto out; + + vol_opt = list_entry (this->volume_options.next, + volume_opt_list_t, list); + list_for_each_entry_safe (vol_opt, tmp, &this->volume_options, list) { + ret = validate_xlator_volume_options_attacherr (this, + vol_opt->given_opt, + op_errstr); } - ret = gf_auth_init (this, auth_modules); out: - if (auth_modules) - dict_unref (auth_modules); return ret; } + static void _delete_auth_opt (dict_t *this, char *key, |