Module: check_mk
Branch: master
Commit: 6d8f4c3ad52e0e6e764b39f63381851e564a7571
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6d8f4c3ad52e0e…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Apr 16 14:08:39 2013 +0200
FIX: do not remove directories of non-exisant users anymore
Conflicts:
ChangeLog
---
ChangeLog | 5 +++++
web/htdocs/userdb.py | 17 ++++++++++-------
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a920e57..ebf450e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -107,6 +107,11 @@
* FIX: check_mk_agent.aix: fix shebang: was python, must be ksh
* FIX: cisco_qos: Be compatible to newer IOS-XE versions (Thanks to Ken Smith)
+ Multisite:
+ * FIX: do not remove directories of non-exisant users anymore. This lead to
+ a deletion of users' settings in case of an external authentication
+ (like mod_ldap).
+
1.2.2:
Core:
* Added $HOSTURL$ and $SERVICEURL$ to notification macros which contain an
diff --git a/web/htdocs/userdb.py b/web/htdocs/userdb.py
index 2d2853a..2dfd104 100644
--- a/web/htdocs/userdb.py
+++ b/web/htdocs/userdb.py
@@ -347,13 +347,16 @@ def save_users(profiles):
serial_file = user_dir + '/serial.mk'
create_user_file(serial_file, 'w').write('%d\n' % user.get('serial', 0))
- # Remove settings directories of non-existant users
- dir = defaults.var_dir + "/web"
- for e in os.listdir(dir):
- if e not in ['.', '..'] and e not in profiles:
- entry = dir + "/" + e
- if os.path.isdir(entry):
- shutil.rmtree(entry)
+ # Remove settings directories of non-existant users.
+ # Beware: we removed this since it leads to violent destructions
+ # if the user database is out of the scope of Check_MK. This is
+ # e.g. the case, if mod_ldap is used for user authentication.
+ # dir = defaults.var_dir + "/web"
+ # for e in os.listdir(dir):
+ # if e not in ['.', '..'] and e not in profiles:
+ # entry = dir + "/" + e
+ # if os.path.isdir(entry):
+ # shutil.rmtree(entry)
# Call the users_saved hook
hooks.call("users-saved", users)
Module: check_mk
Branch: master
Commit: 6454cc5211615533df9a6ad46384e30abbe63904
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6454cc52116155…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Apr 8 12:36:59 2013 +0200
Improved handling of valuespec validations in WATO rule editor
Conflicts:
ChangeLog
---
ChangeLog | 4 ++++
web/htdocs/valuespec.py | 44 +++++++++++++++++++++++++++-----------------
web/htdocs/wato.py | 8 +++++++-
3 files changed, 38 insertions(+), 18 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ebf450e..645dc65 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+<<<<<<< HEAD
1.2.3i1:
Core:
* Agents can send data for other hosts "piggyback". This is being
@@ -111,6 +112,9 @@
* FIX: do not remove directories of non-exisant users anymore. This lead to
a deletion of users' settings in case of an external authentication
(like mod_ldap).
+ WATO:
+ * Improved handling of valuespec validations in WATO rule editor. Displaying a
+ warning message when going to throw away the current settings.
1.2.2:
Core:
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index 2564c00..daf92f5 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -27,6 +27,12 @@
import math, os, time, re, sre_constants, urlparse, forms, htmllib
from lib import *
+def type_name(v):
+ try:
+ return type(v).__name__
+ except:
+ return htmllib.attrencode(type(v))
+
# Abstract base class of all value declaration classes.
class ValueSpec:
def __init__(self, **kwargs):
@@ -190,7 +196,8 @@ class Age(ValueSpec):
def validate_datatype(self, value, varprefix):
if type(value) != int:
- raise MKUserError(varprefix, _("The value %r has type %s, but must be of type int") % (value, type(value)))
+ raise MKUserError(varprefix, _("The value %r has type %s, but must be of type int") %
+ (value, type_name(value)))
# Editor for a single integer
@@ -254,7 +261,7 @@ class Integer(ValueSpec):
def validate_datatype(self, value, varprefix):
if type(value) != int:
raise MKUserError(varprefix, _("The value %r has the wrong type %s, but must be of type int")
- % (value, type(value)))
+ % (value, type_name(value)))
def validate_value(self, value, varprefix):
if self._minvalue != None and value < self._minvalue:
@@ -346,7 +353,8 @@ class TextAscii(ValueSpec):
return
if type(value) != str:
- raise MKUserError(varprefix, _("The value must be of type str, but it has type %s") % type(value))
+ raise MKUserError(varprefix, _("The value must be of type str, but it has type %s") %
+ type_name(value))
def validate_value(self, value, varprefix):
if self._none_is_empty and value == "":
@@ -370,7 +378,8 @@ class TextUnicode(TextAscii):
def validate_datatype(self, value, varprefix):
if type(value) not in [ str, unicode ]:
- raise MKUserError(varprefix, _("The value must be of type str or unicode, but it has type %s") % type(value))
+ raise MKUserError(varprefix, _("The value must be of type str or unicode, but it has type %s") %
+ type_name(value))
# Internal ID as used in many places (for contact names, group name,
# an so on)
@@ -646,7 +655,7 @@ class ListOfStrings(ValueSpec):
def validate_datatype(self, value, vp):
if type(value) != list:
raise MKUserError(varprefix, _("Expected data type is "
- "list, but your type is %s." % type(value)))
+ "list, but your type is %s." % type_name(value)))
for nr, s in enumerate(value):
self._valuespec.validate_datatype(s, vp + "_%d" % nr)
@@ -785,7 +794,7 @@ class ListOf(ValueSpec):
def validate_datatype(self, value, varprefix):
if type(value) != list:
- raise MKUserError(varprefix, _("The type must be list, but is %r") % type(value))
+ raise MKUserError(varprefix, _("The type must be list, but is %s") % type_name(value))
for n, v in enumerate(value):
self._valuespec.validate_datatype(v, varprefix + "_%d" % (n+1))
@@ -823,7 +832,7 @@ class Float(Integer):
if type(value) != float and not \
(type(value) == int and self._accept_int):
raise MKUserError(varprefix, _("The value %r has type %s, but must be of type float%s") %
- (value, type(value), self._accept_int and _(" or int") or ""))
+ (value, type_name(value), self._accept_int and _(" or int") or ""))
class Percentage(Float):
@@ -844,7 +853,7 @@ class Percentage(Float):
if self._allow_int:
if type(value) not in [ int, float ]:
raise MKUserError(varprefix, _("The value %r has type %s, but must be either float or int")
- % (value, type(value)))
+ % (value, type_name(value)))
else:
Float.validate_datatype(self, value, varprefix)
@@ -874,7 +883,8 @@ class Checkbox(ValueSpec):
def validate_datatype(self, value, varprefix):
if type(value) != bool:
- raise MKUserError(varprefix, _("The value %r has type %s, but must be of type bool") % (value, type(value)))
+ raise MKUserError(varprefix, _("The value %r has type %s, but must be of type bool") %
+ (value, type_name(value)))
# A type-save dropdown choice. Parameters:
# help_separator: if you set this to a character, e.g. "-", then
@@ -1212,7 +1222,7 @@ class ListChoice(ValueSpec):
def validate_datatype(self, value, varprefix):
self.load_elements()
if type(value) != list:
- raise MKUserError(varprefix, _("The datatype must be list, but is %s") % type(value))
+ raise MKUserError(varprefix, _("The datatype must be list, but is %s") % type_name(value))
d = dict(self._elements)
for v in value:
if v not in d:
@@ -1463,7 +1473,7 @@ class AbsoluteDate(ValueSpec):
def validate_datatype(self, value, varprefix):
if type(value) not in [ int, float ]:
raise MKUserError(varprefix, _("The type of the timestamp must be int or float, but is %s") %
- type(value))
+ type_name(value))
def validate_value(self, value, varprefix):
if value < 0 or int(value) > (2**31-1):
@@ -1520,14 +1530,14 @@ class Timeofday(ValueSpec):
return
if type(value) != tuple:
- raise MKUserError(varprefix, _("The datatype must be tuple, but ist %s" % type(value)))
+ raise MKUserError(varprefix, _("The datatype must be tuple, but ist %s" % type_name(value)))
if len(value) != 2:
raise MKUserError(varprefix, _("The tuple must contain two elements, but you have %d" % len(value)))
for x in value:
if type(x) != int:
- raise MKUserError(varprefix, _("All elements of the tuple must be of type int, you have %s" % type(x)))
+ raise MKUserError(varprefix, _("All elements of the tuple must be of type int, you have %s" % type_name(x)))
def validate_value(self, value, varprefix):
if not self._allow_empty and value == None:
@@ -1585,7 +1595,7 @@ class TimeofdayRange(ValueSpec):
return
if type(value) != tuple:
- raise MKUserError(varprefix, _("The datatype must be tuple, but ist %s" % type(value)))
+ raise MKUserError(varprefix, _("The datatype must be tuple, but ist %s" % type_name(value)))
if len(value) != 2:
raise MKUserError(varprefix, _("The tuple must contain two elements, but you have %d" % len(value)))
@@ -1862,7 +1872,7 @@ class Tuple(ValueSpec):
def validate_datatype(self, value, varprefix):
if type(value) != tuple:
raise MKUserError(varprefix,
- _("The datatype must be a tuple, but is %r") % type(value))
+ _("The datatype must be a tuple, but is %s") % type_name(value))
if len(value) != len(self._elements):
raise MKUserError(varprefix,
_("The number of elements in the tuple must be exactly %d.") % len(self._elements))
@@ -2074,7 +2084,7 @@ class Dictionary(ValueSpec):
value = self.migrate(value)
if type(value) != dict:
- raise MKUserError(varprefix, _("The type must be a dictionary, but it is a %s") % type(value))
+ raise MKUserError(varprefix, _("The type must be a dictionary, but it is a %s") % type_name(value))
for param, vs in self._get_elements():
if param in value:
@@ -2157,7 +2167,7 @@ class ElementSelection(ValueSpec):
def validate_datatype(self, value, varprefix):
if type(value) != str:
- raise MKUserError(varprefix, _("The datatype must be str (string), but is %s") % type(value))
+ raise MKUserError(varprefix, _("The datatype must be str (string), but is %s") % type_name(value))
class AutoTimestamp(FixedValue):
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 3828f0b..06bcc3c 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -10739,9 +10739,15 @@ def mode_edit_rule(phase, new = False):
try:
valuespec.validate_datatype(value, "ve")
valuespec.render_input("ve", value)
- except:
+ except Exception, e:
if config.debug:
raise
+ else:
+ html.show_warning(_('Unable to read current options of this rule. Falling back to '
+ 'default values. When saving this rule now, your previous settings '
+ 'will be overwritten. Problem was: %s.') % e)
+
+ # In case of validation problems render the input with default values
valuespec.render_input("ve", valuespec.default_value())
valuespec.set_focus("ve")
Module: check_mk
Branch: master
Commit: 5a2bc59b82f515acc288ef810abf65359ed8d00f
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5a2bc59b82f515…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Apr 16 11:08:36 2013 +0200
Fixed problem with snmp_check_interval in inventory check
---
modules/check_mk.py | 2 +-
modules/check_mk_base.py | 5 +++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 432159d..351184d 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -2346,7 +2346,7 @@ def make_inventory(checkname, hostnamelist, check_only=False, include_state=Fals
checkname_base = checkname.split('.')[0] # make e.g. 'lsi' from 'lsi.arrays'
try:
- info = get_realhost_info(hostname, ipaddress, checkname_base, inventory_max_cachefile_age)
+ info = get_realhost_info(hostname, ipaddress, checkname_base, inventory_max_cachefile_age, True)
# Add information about nodes if check wants this
if check_info[checkname]["node_info"]:
if clusters_of(hostname):
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index 56c7de0..b3dd7e2 100755
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -321,7 +321,7 @@ def get_host_info(hostname, ipaddress, checkname):
#
# This function assumes, that each check type is queried
# only once for each host.
-def get_realhost_info(hostname, ipaddress, check_type, max_cache_age):
+def get_realhost_info(hostname, ipaddress, check_type, max_cache_age, ignore_check_interval = False):
info = get_cached_hostinfo(hostname)
if info and info.has_key(check_type):
return info[check_type]
@@ -335,7 +335,8 @@ def get_realhost_info(hostname, ipaddress, check_type, max_cache_age):
if oid_info:
cache_path = tcp_cache_dir + "/" + cache_relpath
check_interval = check_interval_of(hostname, check_type)
- if check_interval is not None and os.path.exists(cache_path) \
+ if not ignore_check_interval \
+ and check_interval is not None and os.path.exists(cache_path) \
and cachefile_age(cache_path) < check_interval:
# cache file is newer than check_interval, skip this check
raise MKSkipCheck()