Module: check_mk
Branch: master
Commit: c44b59c563da41691325fefc2792f2396a091692
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c44b59c563da41…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Mar 9 15:11:22 2016 +0100
3282 FIX Fixed missing validation of network scan properties
The intended validation of network scan properties was not performed correctly.
This was some kind general issue which might also have affected other attributes,
but maybe only the network scan properties were affected.
---
.werks/3282 | 12 ++++++++++++
ChangeLog | 1 +
web/htdocs/wato.py | 14 ++------------
web/htdocs/watolib.py | 19 ++++++++++++++++---
web/plugins/wato/builtin_attributes.py | 2 +-
5 files changed, 32 insertions(+), 16 deletions(-)
diff --git a/.werks/3282 b/.werks/3282
new file mode 100644
index 0000000..fae68c4
--- /dev/null
+++ b/.werks/3282
@@ -0,0 +1,12 @@
+Title: Fixed missing validation of network scan properties
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1457532610
+
+The intended validation of network scan properties was not performed correctly.
+This was some kind general issue which might also have affected other attributes,
+but maybe only the network scan properties were affected.
diff --git a/ChangeLog b/ChangeLog
index 283d591..31bc0ae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -114,6 +114,7 @@
* 3091 FIX: fixed failure to rename hosts in raw edition...
* 3280 FIX: Fixed too often executed network scans...
* 3281 FIX: Fixed network scan overwriting folder modifications made during the scan
+ * 3282 FIX: Fixed missing validation of network scan properties...
Notifications:
* 3263 Notifications: allow users to restrict by their contact groups...
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 84c2e65..6fa1e64 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -15466,20 +15466,10 @@ def configure_attributes(new, hosts, for_what, parent, myself=None, without_attr
if configured_host_tags():
topics.append(_("Host tags"))
- # Hide invisible attributes
- def hide_attribute(for_what, attr):
- if for_what in [ "host", "bulk" ] and not attr.show_in_form():
- return True
- elif for_what == "folder" and not attr.show_in_folder():
- return True
- elif for_what == "host_search" and not attr.show_in_host_search():
- return True
- return False
-
# The remaining topics are shown in the order of the
# appearance of the attribute declarations:
for attr, topic in all_host_attributes():
- if topic not in topics and not hide_attribute(for_what, attr):
+ if topic not in topics and attr.is_visible(for_what):
topics.append(topic)
# Collect dependency mapping for attributes (attributes that are only
@@ -15512,7 +15502,7 @@ def configure_attributes(new, hosts, for_what, parent, myself=None, without_attr
continue # e.g. needed to skip ipaddress in CSV-Import
# Determine visibility information if this attribute is not always hidden
- if not hide_attribute(for_what, attr):
+ if attr.is_visible(for_what):
depends_on_tags = attr.depends_on_tags()
depends_on_roles = attr.depends_on_roles()
# Add host tag dependencies, but only in host mode. In other
diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py
index 1c4a052..b3bc60c 100644
--- a/web/htdocs/watolib.py
+++ b/web/htdocs/watolib.py
@@ -2310,11 +2310,24 @@ class Attribute:
# Check whether this attribute needs to be validated at all
# Attributes might be permanently hidden (show_in_form = False)
# or dynamically hidden by the depends_on_tags, editable features
- def needs_validation(self):
- if not self._show_in_form:
+ def needs_validation(self, for_what):
+ if not self.is_visible(for_what):
return False
return html.var('attr_display_%s' % self._name, "1") == "1"
+
+ # Gets the type of current view as argument and returns whether or not
+ # this attribute is shown in this type of view
+ def is_visible(self, for_what):
+ if for_what in [ "host", "bulk" ] and not self.show_in_form():
+ return False
+ elif for_what == "folder" and not self.show_in_folder():
+ return False
+ elif for_what == "host_search" and not self.show_in_host_search():
+ return False
+ return True
+
+
# Check if the value entered by the user is valid.
# This method may raise MKUserError in case of invalid user input.
def validate_input(self, varprefix):
@@ -2807,7 +2820,7 @@ def collect_attributes(for_what, do_validate = True, varprefix=""):
if not html.var(for_what + "_change_%s" % attrname, False):
continue
- if do_validate and attr.needs_validation():
+ if do_validate and attr.needs_validation(for_what):
attr.validate_input(varprefix)
host[attrname] = attr.from_html_vars(varprefix)
diff --git a/web/plugins/wato/builtin_attributes.py b/web/plugins/wato/builtin_attributes.py
index 8657c19..b58d653 100644
--- a/web/plugins/wato/builtin_attributes.py
+++ b/web/plugins/wato/builtin_attributes.py
@@ -161,7 +161,7 @@ class NetworkScanAttribute(ValueSpecAttribute):
title = _("Scan interval"),
display = [ "days", "hours" ],
default_value = 60*60*24,
- min_value = 3600, # 1 hour
+ minvalue = 3600, # 1 hour
)),
("max_parallel_pings", Integer(
title = _("Parallel pings to send"),
Module: check_mk
Branch: master
Commit: 3f372485dd02200d9423596562f5c01772635ffe
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3f372485dd0220…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Mar 9 14:57:54 2016 +0100
3281 FIX Fixed network scan overwriting folder modifications made during the scan
---
.werks/3281 | 10 ++++++++++
ChangeLog | 1 +
web/htdocs/wato.py | 12 ++++++++++--
3 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/.werks/3281 b/.werks/3281
new file mode 100644
index 0000000..70ff88b
--- /dev/null
+++ b/.werks/3281
@@ -0,0 +1,10 @@
+Title: Fixed network scan overwriting folder modifications made during the scan
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1457531844
+
+
diff --git a/ChangeLog b/ChangeLog
index 6d5bf27..283d591 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -113,6 +113,7 @@
* 3086 FIX: fixed incorrect host list when one wato folder was a substring of another...
* 3091 FIX: fixed failure to rename hosts in raw edition...
* 3280 FIX: Fixed too often executed network scans...
+ * 3281 FIX: Fixed network scan overwriting folder modifications made during the scan
Notifications:
* 3263 Notifications: allow users to restrict by their contact groups...
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index e8bd23a..84c2e65 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -15055,8 +15055,16 @@ def add_scanned_hosts_to_folder(folder, found):
def save_network_scan_result(folder, result):
- folder.set_attribute("network_scan_result", result)
- folder.save()
+ # Reload the folder, lock WATO before to protect against concurrency problems.
+ lock_exclusive()
+
+ # A user might have changed the folder somehow since starting the scan. Load the
+ # folder again to get the current state.
+ write_folder = Folder.folder(folder.path())
+ write_folder.set_attribute("network_scan_result", result)
+ write_folder.save()
+
+ unlock_exclusive()
# This is executed in the site the host is assigned to.
Module: check_mk
Branch: master
Commit: 14a9eaf1effa740dd15e4f7a80b960da826ac427
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=14a9eaf1effa74…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Mar 9 14:44:12 2016 +0100
3280 FIX Fixed too often executed network scans
The network scan interval was not handled correctly and network scan of a folder
could be executed multiple time in parallel if running more than 1 minute.
---
.werks/3280 | 11 +++++++++++
ChangeLog | 1 +
web/htdocs/wato.py | 20 +++++++++++---------
web/plugins/wato/builtin_attributes.py | 3 +++
4 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/.werks/3280 b/.werks/3280
new file mode 100644
index 0000000..32ad0c2
--- /dev/null
+++ b/.werks/3280
@@ -0,0 +1,11 @@
+Title: Fixed too often executed network scans
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1457530987
+
+The network scan interval was not handled correctly and network scan of a folder
+could be executed multiple time in parallel if running more than 1 minute.
diff --git a/ChangeLog b/ChangeLog
index aa12e38..e95622a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -111,6 +111,7 @@
* 3231 FIX: Not showing network scan properties in host search form anymore
* 3086 FIX: fixed incorrect host list when one wato folder was a substring of another...
* 3091 FIX: fixed failure to rename hosts in raw edition...
+ * 3280 FIX: Fixed too often executed network scans...
Notifications:
* 3263 Notifications: allow users to restrict by their contact groups...
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 8ad268c..e8bd23a 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -14974,11 +14974,16 @@ def execute_network_scan_job():
result = {
"start" : time.time(),
- "end" : None,
+ "end" : True, # means currently running
"state" : None,
- "output" : "",
+ "output" : "The scan is currently running.",
}
+ # Mark the scan in progress: Is important in case the request takes longer than
+ # the interval of the cron job (1 minute). Otherwise the scan might be started
+ # a second time before the first one finished.
+ save_network_scan_result(folder, result)
+
try:
if config.site_is_local(folder.site_id()):
found = do_network_scan(folder)
@@ -15017,7 +15022,7 @@ def find_folder_to_scan():
folder_to_scan = None
for folder_path, folder in Folder.all_folders().items():
scheduled_time = folder.next_network_scan_at()
- if scheduled_time != None:
+ if scheduled_time != None and scheduled_time < time.time():
if folder_to_scan == None:
folder_to_scan = folder
elif folder_to_scan.next_network_scan_at() > folder.next_network_scan_at():
@@ -15163,7 +15168,7 @@ def ping_worker(addresses, hosts):
while True:
try:
ipaddress = addresses.pop()
- except IndexError:
+ except KeyError:
break
if ping(ipaddress):
@@ -15194,11 +15199,8 @@ def scan_ip_addresses(folder, ip_addresses):
t.start()
# Now wait for all workers to finish
- while threads:
- for t in threads:
- if not t.isAlive():
- threads.remove(t)
- time.sleep(1)
+ for t in threads:
+ t.join()
return found_hosts
diff --git a/web/plugins/wato/builtin_attributes.py b/web/plugins/wato/builtin_attributes.py
index 75f2100..8657c19 100644
--- a/web/plugins/wato/builtin_attributes.py
+++ b/web/plugins/wato/builtin_attributes.py
@@ -261,6 +261,9 @@ class NetworkScanResultAttribute(ValueSpecAttribute):
FixedValue(None,
totext = _("No scan has finished yet."),
),
+ FixedValue(True,
+ totext = "", # currently running
+ ),
AbsoluteDate(
include_time = True,
default_value = 0,
Module: check_mk
Branch: master
Commit: db9307d52ed735a03f507a6b4f83c57493b660e8
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=db9307d52ed735…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Mar 9 13:38:15 2016 +0100
3279 FIX LDAP: Fixed default values of attribute selections
For several LDAP sync plugins it is possible to configure the LDAP attribute
for syncing. For example for the mail sync plugin you can configure which LDAP
attribute to use as source for the mail address.
The default values of these attributes depend on the selected LDAP type. This
special case was not working in 1.2.8x and has beend fixed now.
---
.werks/3279 | 15 +++++++++++++++
ChangeLog | 1 +
web/htdocs/wato.py | 6 +++---
web/plugins/userdb/ldap.py | 35 +++++++++++++++++++++++++++++------
4 files changed, 48 insertions(+), 9 deletions(-)
diff --git a/.werks/3279 b/.werks/3279
new file mode 100644
index 0000000..09fe275
--- /dev/null
+++ b/.werks/3279
@@ -0,0 +1,15 @@
+Title: LDAP: Fixed default values of attribute selections
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1457526988
+
+For several LDAP sync plugins it is possible to configure the LDAP attribute
+for syncing. For example for the mail sync plugin you can configure which LDAP
+attribute to use as source for the mail address.
+
+The default values of these attributes depend on the selected LDAP type. This
+special case was not working in 1.2.8x and has beend fixed now.
diff --git a/ChangeLog b/ChangeLog
index 80e5052..aa12e38 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -87,6 +87,7 @@
* 3273 FIX: Dashboard: The dashboard is now preserving edit/view state during page reloads
* 3090 FIX: fixed perf-o-meter link leading to old graph page even when new graphs are being used
* 3260 FIX: Availability: ignores completely unmonitored objects in summary calculation
+ * 3279 FIX: LDAP: Fixed default values of attribute selections...
WATO:
* 3244 WATO BI Module: swap order of aggregation function and child node selection...
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 5af65de..8ad268c 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -5612,7 +5612,7 @@ def validate_ldap_connection_id(value, varprefix):
raise MKUserError(varprefix, _("This ID is already user by another connection. Please choose another one."))
-def vs_ldap_connection(new):
+def vs_ldap_connection(new, connection_id):
if new:
general_elements = [
("id", TextAscii(
@@ -5880,7 +5880,7 @@ def vs_ldap_connection(new):
'or disabled. When enabling a plugin, it is used upon the next synchonisation of '
'user accounts for gathering their attributes. The user options which get imported '
'into Check_MK from LDAP will be locked in WATO.'),
- elements = userdb.ldap_attribute_plugins_elements,
+ elements = lambda: userdb.ldap_attribute_plugins_elements(connection_id),
default_keys = ['email', 'alias', 'auth_expire' ],
)),
("cache_livetime", Age(
@@ -5956,7 +5956,7 @@ def mode_edit_ldap_connection(phase):
html.context_button(_("Back"), folder_preserving_link([("mode", "ldap_config")]), "back")
return
- vs = vs_ldap_connection(new)
+ vs = vs_ldap_connection(new, connection_id)
if phase == 'action':
if not html.check_transaction():
diff --git a/web/plugins/userdb/ldap.py b/web/plugins/userdb/ldap.py
index 5b57b9d..db86eba 100644
--- a/web/plugins/userdb/ldap.py
+++ b/web/plugins/userdb/ldap.py
@@ -24,6 +24,10 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
+# TODO FIXME: Change attribute sync plugins to classes. The current dict
+# based approach is not very readable. Classes/objects make it a lot
+# easier to understand the mechanics.
+
# .--Declarations--------------------------------------------------------.
# | ____ _ _ _ |
# | | _ \ ___ ___| | __ _ _ __ __ _| |_(_) ___ _ __ ___ |
@@ -46,9 +50,11 @@ try:
# be compatible to both python-ldap below 2.4 and above
try:
+ # pylint: disable=no-member
LDAP_CONTROL_PAGED_RESULTS = ldap.LDAP_CONTROL_PAGE_OID
ldap_compat = False
except:
+ # pylint: disable=no-member
LDAP_CONTROL_PAGED_RESULTS = ldap.CONTROL_PAGEDRESULTS
ldap_compat = True
except:
@@ -1134,7 +1140,10 @@ def ldap_list_attribute_plugins():
return plugins
# Returns a list of pairs (key, parameters) of all available attribute plugins
-def ldap_attribute_plugins_elements():
+def ldap_attribute_plugins_elements(connection_id):
+ global g_editing_connection_id
+ g_editing_connection_id = connection_id
+
register_user_attribute_sync_plugins()
elements = []
@@ -1185,11 +1194,25 @@ def register_user_attribute_sync_plugins():
('attr', TextAscii(
title = _("LDAP attribute to sync"),
help = _("The LDAP attribute whose contents shall be synced into this custom attribute."),
- default_value = lambda: ldap_attr(attr),
+ default_value = lambda: ldap_attr_of_connection(g_editing_connection_id, attr),
)),
],
}
+# This hack is needed to make the connection_id of the connection currently
+# being edited (or None if being created) available in the "default_value"
+# handler functions of the valuespec. There is no other standard way to
+# transport this info to these functions.
+g_editing_connection_id = None
+
+# Helper function for gathering the default LDAP attribute names of a connection.
+def ldap_attr_of_connection(connection_id, attr):
+ connection = get_connection(connection_id)
+ if not connection:
+ return None
+
+ return connection.ldap_attr(attr)
+
def ldap_sync_simple(user_id, ldap_user, user, user_attr, attr):
if attr in ldap_user:
@@ -1304,7 +1327,7 @@ ldap_attribute_plugins['email'] = {
("attr", TextAscii(
title = _("LDAP attribute to sync"),
help = _("The LDAP attribute containing the mail address of the user."),
- default_value = lambda: ldap_attr('mail'),
+ default_value = lambda: ldap_attr_of_connection(g_editing_connection_id, 'mail'),
)),
],
}
@@ -1340,7 +1363,7 @@ ldap_attribute_plugins['alias'] = {
("attr", TextAscii(
title = _("LDAP attribute to sync"),
help = _("The LDAP attribute containing the alias of the user."),
- default_value = lambda: ldap_attr('cn'),
+ default_value = lambda: ldap_attr_of_connection(g_editing_connection_id, 'cn'),
)),
],
}
@@ -1421,7 +1444,7 @@ ldap_attribute_plugins['auth_expire'] = {
"current authenticated sessions of the user are invalidated and the "
"user must login again. By default this field uses the fields which "
"hold the time of the last password change of the user."),
- default_value = lambda: ldap_attr('pw_changed'),
+ default_value = lambda: ldap_attr_of_connection(g_editing_connection_id, 'pw_changed'),
)),
],
}
@@ -1457,7 +1480,7 @@ ldap_attribute_plugins['pager'] = {
('attr', TextAscii(
title = _("LDAP attribute to sync"),
help = _("The LDAP attribute containing the pager number of the user."),
- default_value = lambda: ldap_attr('mobile'),
+ default_value = lambda: ldap_attr_of_connection(g_editing_connection_id, 'mobile'),
)),
],
}
Module: check_mk
Branch: master
Commit: 039c8476d9e3c09fb6dc5674a3d00d114eeb910a
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=039c8476d9e3c0…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Mar 9 10:59:57 2016 +0100
Updated bug entries #2428
---
.bugs/2428 | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/.bugs/2428 b/.bugs/2428
new file mode 100644
index 0000000..a845f75
--- /dev/null
+++ b/.bugs/2428
@@ -0,0 +1,11 @@
+Title: Make a clean install of the agents/ directory
+Component: core
+State: open
+Date: 2016-03-09 10:58:31
+Targetversion: 1.2.8
+Class: bug
+
+The contents of the source code direcgory agents/ in the GIT cannot shipped 1:1
+into the Check_MK site anylonger. We need an installation script of the like that
+e.g. tars the source codes into nice tarballs, skips internal files and presents
+a nice list of files for download on the Agents page in WATO.