Module: check_mk
Branch: master
Commit: 8e37367c0657d7b368f9c7aa25107c5439d137e6
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8e37367c0657d7…
Author: Andreas <ab(a)mathias-kettner.de>
Date: Thu Jun 14 18:57:20 2018 +0200
5822 FIX WATO Web-API set_ruleset: Now able to delete complete rulesets from folders
Removing all rulesets of a specific type from a folder always failed with the exception
<tt>'list' object has no attribute 'get'</tt>. This has been fixed.
Change-Id: Ie39dd3e99ec0d2a8b21c7abcad6174e7d7e64417
---
.werks/5822 | 13 +++++++++++++
web/plugins/webapi/webapi.py | 9 +++++----
2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/.werks/5822 b/.werks/5822
new file mode 100644
index 0000000..b4ab409
--- /dev/null
+++ b/.werks/5822
@@ -0,0 +1,13 @@
+Title: WATO Web-API set_ruleset: Now able to delete complete rulesets from folders
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1528995338
+
+Removing all rulesets of a specific type from a folder always failed with the exception
+<tt>'list' object has no attribute 'get'</tt>. This has been fixed.
+
diff --git a/web/plugins/webapi/webapi.py b/web/plugins/webapi/webapi.py
index 0b4b4a5..fe047f6 100644
--- a/web/plugins/webapi/webapi.py
+++ b/web/plugins/webapi/webapi.py
@@ -783,15 +783,16 @@ class APICallRules(APICallCollection):
for folder_path in folders_obsolete_ruleset:
folder = watolib.Folder.folder(folder_path)
- folder_rulesets = watolib.FolderRulesets(ruleset_name)
- # TODO: Shouldn't this call .load()?
-
+ folder_rulesets = watolib.FolderRulesets(folder)
+ folder_rulesets.load()
# TODO: This add_change() call should be made by the data classes
watolib.add_change("edit-ruleset", _("Deleted ruleset '%s' for '%s'") %
(watolib.Ruleset(ruleset_name).title(), folder.title()),
sites=folder.all_site_ids())
- folder_rulesets.from_config(folder, [])
+ new_ruleset = watolib.Ruleset(ruleset_name)
+ new_ruleset.from_config(folder, [])
+ folder_rulesets.set(ruleset_name, new_ruleset)
folder_rulesets.save()
Module: check_mk
Branch: master
Commit: 83b8c282655b612b48f3370be0fa0c6c3994dfcc
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=83b8c282655b61…
Author: Andreas <ab(a)mathias-kettner.de>
Date: Thu Jun 14 17:39:20 2018 +0200
5821 FIX Fixed exception during configuration changes
This exception could happens on various instances. For example
when saving global settings or during the activate changes phase.
The exception text showed <tt>super(type, obj): obj must be an instance or subtype of type</tt>.
Change-Id: Iac78617d4be8f802915cda1ebf08d09694f50878
---
.werks/5821 | 14 ++++++++++++++
web/htdocs/backup.py | 2 ++
web/htdocs/gui_background_job.py | 9 ++++++++-
web/htdocs/watolib.py | 11 +++++++----
web/plugins/webapi/webapi.py | 6 +++++-
5 files changed, 36 insertions(+), 6 deletions(-)
diff --git a/.werks/5821 b/.werks/5821
new file mode 100644
index 0000000..bb96df8
--- /dev/null
+++ b/.werks/5821
@@ -0,0 +1,14 @@
+Title: Fixed exception during configuration changes
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1528990598
+
+This exception could happens on various instances. For example
+when saving global settings or during the activate changes phase.
+
+The exception text showed <tt>super(type, obj): obj must be an instance or subtype of type</tt>.
diff --git a/web/htdocs/backup.py b/web/htdocs/backup.py
index f5bc8a2..f8adad4 100644
--- a/web/htdocs/backup.py
+++ b/web/htdocs/backup.py
@@ -1297,6 +1297,7 @@ class BackupTargetType(object):
@classmethod
def choices(cls):
choices = []
+ # TODO: subclasses with the same name may be registered multiple times, due to execfile
for type_class in cls.__subclasses__(): # pylint: disable=no-member
choices.append((type_class.ident, type_class.title(), type_class.valuespec()))
return sorted(choices, key=lambda x: x[1])
@@ -1304,6 +1305,7 @@ class BackupTargetType(object):
@classmethod
def get_type(cls, type_ident):
+ # TODO: subclasses with the same name may be registered multiple times, due to execfile
for type_class in cls.__subclasses__(): # pylint: disable=no-member
if type_class.ident == type_ident:
return type_class
diff --git a/web/htdocs/gui_background_job.py b/web/htdocs/gui_background_job.py
index 077846c..63c7cdf 100644
--- a/web/htdocs/gui_background_job.py
+++ b/web/htdocs/gui_background_job.py
@@ -185,8 +185,15 @@ class GUIBackgroundJob(GUIBackgroundJobSnapshottedFunctions, background_job.Back
@classmethod
def get_concrete_subclasses(cls):
- all_subclasses = []
+ # Note: Due to the strange execfile plugin mechanism, there is a risk
+ # that a class gets declared multiple times. We always use the last
+ # declaration of the given class
+ classes = {}
for subclass in cls.__subclasses__(): # pylint: disable=no-member
+ classes[subclass.__name__] = subclass
+
+ all_subclasses = []
+ for subclass in classes.values():
# Concrete subclasses have an attribute job_prefix
if hasattr(subclass, "job_prefix"):
all_subclasses.append(subclass)
diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py
index b9181cd..655cdc9 100644
--- a/web/htdocs/watolib.py
+++ b/web/htdocs/watolib.py
@@ -282,13 +282,16 @@ class ConfigDomain(object):
@classmethod
def all_classes(cls):
- subclasses = cls.__subclasses__() # pylint: disable=no-member
-
# Classes may be registered twice, only store one of the occurances.
# TODO(lm): Find the reason for this and solve this issue in the plugin mechanism.
+ # NOTE: One reason is the rampant execfile usage in the plugin folders
+ # each language change creates additional class definitions
+
+ # The latest "fix" changes the behaviour to return the last declared class with the
+ # same class name. This is usually a better idea, than returning outdated classes
classes = {}
- for subclass in subclasses:
- classes.setdefault(subclass.__name__, subclass)
+ for subclass in cls.__subclasses__(): # pylint: disable=no-member
+ classes[subclass.__name__] = subclass
return classes.values()
diff --git a/web/plugins/webapi/webapi.py b/web/plugins/webapi/webapi.py
index ee553fe..0b4b4a5 100644
--- a/web/plugins/webapi/webapi.py
+++ b/web/plugins/webapi/webapi.py
@@ -134,7 +134,11 @@ def add_configuration_hash(response, configuration_object):
class APICallCollection(object):
@classmethod
def all_classes(cls):
- return cls.__subclasses__() # pylint: disable=no-member
+ classes = {}
+ for subclass in cls.__subclasses__(): # pylint: disable=no-member
+ classes[subclass.__name__] = subclass
+
+ return classes.values()
def get_api_calls(self):
Module: check_mk
Branch: master
Commit: e0290a1ec3d49058e0847ce8b5cd1fb9c66ed340
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e0290a1ec3d490…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Thu Jun 14 14:50:48 2018 +0200
Move the non-constant state out of check_api.
This module should basically act as a template for checks contexts, having
modifiable state in it which is shared across all contexts is highly
obscure. Furthermore, this decouples checks and check_api a bit more, we
are currently left with a single connection in that direction.
Change-Id: I6a101019d247ef3bcc4b54165bd4dbe74b38b1df
---
cmk_base/automations/check_mk.py | 3 ++-
cmk_base/check_api.py | 30 ++++++------------------------
cmk_base/check_api_utils.py | 36 ++++++++++++++++++++++++++++++++++++
cmk_base/check_table.py | 3 ++-
cmk_base/checking.py | 5 +++--
cmk_base/checks.py | 11 +----------
cmk_base/core_nagios.py | 3 ++-
cmk_base/discovery.py | 4 ++--
cmk_base/snmp_scan.py | 3 ++-
9 files changed, 56 insertions(+), 42 deletions(-)
Diff: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=e0290a1ec3…
Module: check_mk
Branch: master
Commit: 2676b456202da54229cb5a38dd0f8632e5f654f6
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2676b456202da5…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Thu Jun 14 12:13:49 2018 +0200
Moved some check API constants to a separate module for now.
This reduces the imports of check_api and is a prerequisite for breaking two
cycles. More to come...
Change-Id: Iaabcbfb09b83519e46263fee7a0ff4381683ca78
---
cmk_base/check_api.py | 18 +++++--------
cmk_base/check_api_utils.py | 54 +++++++++++++++++++++++++++++++++++++++
cmk_base/checks.py | 13 +++++-----
cmk_base/data_sources/abstract.py | 4 +--
cmk_base/discovery.py | 6 ++---
cmk_base/inventory.py | 8 +++---
6 files changed, 77 insertions(+), 26 deletions(-)
Diff: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=2676b45620…