summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-op-sm.c
diff options
context:
space:
mode:
authorKaleb S. KEITHLEY <kkeithle@redhat.com>2017-08-01 08:04:48 -0400
committerShyamsundar Ranganathan <srangana@redhat.com>2017-08-03 12:03:18 +0000
commitf68887999e89d894c3125e3b26517221ad1543fc (patch)
tree36a9371653aaa939d2781735103182fd6081387b /xlators/mgmt/glusterd/src/glusterd-op-sm.c
parentc7e5741f938e24b85976bf78ea7d84984a4e1e61 (diff)
logging: localtime logging, cmdline, volume set option
Despite the fact that appliances generally use UTC, some users really want log entries in localtime. fixes gluster/glusterfs#272 feature page: https://review.gluster.org/17807 Change-Id: I5fbf2c3eedd9eb128fb3f851dd67b2f4081c8bba Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com> Reviewed-on: https://review.gluster.org/16911 CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Samikshan Bairagya <samikshan@gmail.com> Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-op-sm.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c66
1 files changed, 65 insertions, 1 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 6be92d8ad7e..7bb3d537097 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -85,6 +85,7 @@ glusterd_all_vol_opts valid_all_vol_opts[] = {
* TBD: Discuss the default value for this. Maybe this should be a
* dynamic value depending on the memory specifications per node */
{ GLUSTERD_BRICKMUX_LIMIT_KEY, "0"},
+ { GLUSTERD_LOCALTIME_LOGGING_KEY, "disable"},
{ NULL },
};
@@ -870,6 +871,60 @@ out:
}
static int
+glusterd_validate_localtime_logging (char *key, char *value, char *errstr)
+{
+ int32_t ret = -1;
+ xlator_t *this = NULL;
+ glusterd_conf_t *conf = NULL;
+ int already_enabled = 0;
+
+ this = THIS;
+ GF_VALIDATE_OR_GOTO ("glusterd", this, out);
+
+ conf = this->private;
+ GF_VALIDATE_OR_GOTO (this->name, conf, out);
+
+ GF_VALIDATE_OR_GOTO (this->name, key, out);
+ GF_VALIDATE_OR_GOTO (this->name, value, out);
+ GF_VALIDATE_OR_GOTO (this->name, errstr, out);
+
+ ret = 0;
+
+ if (strcmp (key, GLUSTERD_LOCALTIME_LOGGING_KEY)) {
+ goto out;
+ }
+
+ if ((strcmp (value, "enable")) &&
+ (strcmp (value, "disable"))) {
+ snprintf (errstr, PATH_MAX,
+ "Invalid option(%s). Valid options "
+ "are 'enable' and 'disable'", value);
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY, "%s", errstr);
+ ret = -1;
+ }
+
+ already_enabled = gf_log_get_localtime ();
+
+ if (strcmp (value, "enable") == 0) {
+ gf_log_set_localtime (1);
+ if (!already_enabled)
+ gf_msg (this->name, GF_LOG_INFO, 0,
+ GD_MSG_LOCALTIME_LOGGING_ENABLE,
+ "localtime logging enable");
+ } else if (strcmp (value, "disable") == 0) {
+ gf_log_set_localtime (0);
+ if (already_enabled)
+ gf_msg (this->name, GF_LOG_INFO, 0,
+ GD_MSG_LOCALTIME_LOGGING_DISABLE,
+ "localtime logging disable");
+ }
+
+out:
+ return ret;
+}
+
+static int
glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
{
int ret = -1;
@@ -1253,6 +1308,14 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
goto out;
}
+ ret = glusterd_validate_localtime_logging (key, value, errstr);
+ if (ret) {
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_LOCALTIME_LOGGING_VOL_OPT_VALIDATE_FAIL,
+ "Failed to validate localtime "
+ "logging volume options");
+ goto out;
+ }
if (volinfo) {
ret = glusterd_volinfo_get (volinfo,
@@ -2639,6 +2702,7 @@ out:
return ret;
}
+
int
glusterd_op_get_max_opversion (char **op_errstr, dict_t *rsp_dict)
{
@@ -2658,6 +2722,7 @@ out:
return ret;
}
+
static int
glusterd_set_shared_storage (dict_t *dict, char *key, char *value,
char **op_errstr)
@@ -2735,7 +2800,6 @@ out:
}
-
static int
glusterd_op_set_volume (dict_t *dict, char **errstr)
{