Module: check_mk
Branch: master
Commit: 253c075d8917e03901b1a821ee4b2141fc993e4b
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=253c075d8917e0…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Wed Jul 24 16:16:24 2013 +0200
* Add: Require unique alias names in between the following elements:
Host/Service/Contact Groups, Timeperiods and Roles
---
ChangeLog | 2 ++
web/htdocs/wato.py | 39 ++++++++++++++++++++++++++++++++++++---
2 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d19de41..b92bf12 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -106,6 +106,8 @@
* Custom user attributes can now be managed using WATO
* FIX: do validation of check items in rule editor
* FIX: More consistent handling of folderpath select in rule editor
+ * Add: Require unique alias names in between the following elements:
+ Host/Service/Contact Groups, Timeperiods and Roles
Notifications:
* Flexible Notification can now filter service levels
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 9b610f4..c5cf0e6 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -5860,9 +5860,11 @@ def mode_edit_group(phase, what):
alias = html.var_utf8("alias").strip()
if not alias:
raise MKUserError("alias", _("Please specify an alias name."))
- for key, value in groups.items():
- if alias == value and name != key:
- raise MKUserError("alias", _("This alias is already used in the group %s .") % key)
+
+ unique, info = is_alias_used(what, name, alias)
+ if not unique:
+ raise MKUserError("alias", info)
+
if new:
name = html.var("name").strip()
if len(name) == 0:
@@ -6204,6 +6206,10 @@ def mode_edit_timeperiod(phase):
if not alias:
raise MKUserError("alias", _("Please specify an alias name for your timeperiod."))
+ unique, info = is_alias_used("timeperiods", name, alias)
+ if not unique:
+ raise MKUserError("alias", info)
+
timeperiod.clear()
# extract time ranges of weekdays
@@ -8642,6 +8648,11 @@ def mode_edit_role(phase):
if phase == "action":
alias = html.var_utf8("alias")
+
+ unique, info = is_alias_used("roles", id, alias)
+ if not unique:
+ raise MKUserError("alias", info)
+
new_id = html.var("id")
if len(new_id) == 0:
raise MKUserError("id", _("Please specify an ID for the new role."))
@@ -13556,6 +13567,28 @@ def may_see_hosts():
return config.may("wato.use") and \
(config.may("wato.seeall") or config.may("wato.hosts"))
+def is_alias_used(my_group, my_name, aliasname):
+ # Host / Service / Contact groups
+ all_groups = userdb.load_group_information()
+ for groupname, group in all_groups.items():
+ for key, value in group.items():
+ if value == aliasname and (my_group != groupname or my_name != key):
+ return False, _("This alias is already used in the %s group %s .") % (groupname, key)
+
+ # Timeperiods
+ timeperiods = load_timeperiods()
+ for key, value in timeperiods.items():
+ if value.get("alias") == aliasname and (my_group != "timeperiod" or my_name != key):
+ return False, _("This alias is already used in timeperiod %s.") % key
+
+ # Roles
+ roles = userdb.load_roles()
+ for key, value in roles.items():
+ if value.get("alias") == aliasname and (my_group != "roles" or my_name != key):
+ return False, _("This alias is already used in the role %s.") % key
+
+ return True, None
+
#.
# .-Plugins--------------------------------------------------------------.
# | ____ _ _ |
Module: check_mk
Branch: master
Commit: c6e0110652125e79aca6e66d715c1d5882545bd6
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c6e0110652125e…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Jul 24 14:30:51 2013 +0200
ldap: Always using lower case ldap attributes
---
web/plugins/userdb/ldap.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/web/plugins/userdb/ldap.py b/web/plugins/userdb/ldap.py
index 85c4069..60f6aae 100644
--- a/web/plugins/userdb/ldap.py
+++ b/web/plugins/userdb/ldap.py
@@ -311,8 +311,9 @@ def ldap_filter(key, handle_config = True):
# Returns the ldap attribute name depending on the configured ldap directory type
# If a key is not present in the map, the assumption is, that the key matches 1:1
+# Always use lower case here, just to prevent confusions.
def ldap_attr(key):
- return ldap_attr_map[config.ldap_connection['type']].get(key, key)
+ return ldap_attr_map[config.ldap_connection['type']].get(key, key).lower()
# Returns the given distinguished name template with replaced vars
def ldap_replace_macros(tmpl):
@@ -718,6 +719,8 @@ def ldap_sync(add_to_changelog, only_username):
ldap_connect()
+ ldap_log(' SYNC PLUGINS: %s' % ', '.join(config.ldap_active_plugins.keys()))
+
# Unused at the moment, always sync all users
#filt = None
#if only_username:
Module: check_mk
Branch: master
Commit: f30bc9a6d619d742d54b07e67e8e62187fecc1bd
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f30bc9a6d619d7…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Jul 24 12:02:26 2013 +0200
Fix DST error in AbsoluteDate Valuespec wit new time feature
---
web/htdocs/valuespec.py | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index 2803593..4cad688 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -1522,7 +1522,16 @@ class AbsoluteDate(ValueSpec):
if part < mmin or part > mmax:
raise MKUserError(varname, _("The value for %s must be between %d and %d" % (_(what), mmin, mmax)))
parts.append(part)
+
+ # Construct broken time from input fields. Assume no-dst
parts += [0] * (self._include_time and 3 or 6)
+ # Convert to epoch
+ epoch = time.mktime(tuple(parts))
+ # Convert back to localtime in order to know DST setting
+ localtime = time.localtime(epoch)
+ # Enter DST setting of that time
+ parts[-1] = localtime.tm_isdst
+ # Convert to epoch again
return time.mktime(tuple(parts))
def validate_datatype(self, value, varprefix):