diff options
author | shishir gowda <shishirng@gluster.com> | 2010-10-11 03:49:45 +0000 |
---|---|---|
committer | Vijay Bellur <vijay@dev.gluster.com> | 2010-10-11 03:32:50 -0700 |
commit | 81b6fa2b813d6913dd6329ef6a463669d282ebb6 (patch) | |
tree | 7dfc25a829e904b39af5986eb7e604206b213bcd | |
parent | 3dc782527482d2c62c9344669ccaa2dc42481a58 (diff) |
Add log-level validation for volume set command
Signed-off-by: shishir gowda <shishirng@gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>
BUG: 1886 (log-level mess)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1886
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volgen.c | 32 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volgen.h | 1 |
2 files changed, 32 insertions, 1 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index df4818df82f..987449942e5 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -738,6 +738,8 @@ loglevel_option_handler (glusterfs_graph_t *graph, !strstr (vme->key, role)) return 0; + if (glusterd_check_log_level(vme->value) == -1) + return -1; memcpy (&vme2, vme, sizeof (vme2)); vme2.option = "log-level"; @@ -1387,4 +1389,32 @@ glusterd_validate_reconfopts (glusterd_volinfo_t *volinfo, dict_t *val_dict, out: gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); return ret; -}
\ No newline at end of file +} + +int +glusterd_check_log_level (const char *value) +{ + int log_level = -1; + + if (!strcasecmp (value, "CRITICAL")) { + log_level = GF_LOG_CRITICAL; + } else if (!strcasecmp (value, "ERROR")) { + log_level = GF_LOG_ERROR; + } else if (!strcasecmp (value, "WARNING")) { + log_level = GF_LOG_WARNING; + } else if (!strcasecmp (value, "INFO")) { + log_level = GF_LOG_INFO; + } else if (!strcasecmp (value, "DEBUG")) { + log_level = GF_LOG_DEBUG; + } else if (!strcasecmp (value, "TRACE")) { + log_level = GF_LOG_TRACE; + } else if (!strcasecmp (value, "NONE")) { + log_level = GF_LOG_NONE; + } + + if (log_level == -1) + gf_log ("", GF_LOG_ERROR, "Invalid log-level. possible values " + "are DEBUG|WARNING|ERROR|CRITICAL|NONE|TRACE"); + + return log_level; +} diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.h b/xlators/mgmt/glusterd/src/glusterd-volgen.h index 16bf1c73ea4..95f61383b82 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.h +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.h @@ -41,4 +41,5 @@ int glusterd_delete_volfile (glusterd_volinfo_t *volinfo, int glusterd_volinfo_get (glusterd_volinfo_t *volinfo, char *key, char **value); +int glusterd_check_log_level (const char *log_level); #endif |