Module: check_mk
Branch: master
Commit: df6b2fd8b55d14e2a8194b10f98110af680e9067
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=df6b2fd8b55d14…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Sat Feb 23 21:01:00 2019 +0100
Improved locked host attributes handling
* Attributes are not editable when creating hosts / folders
* Both attributes now display "Not locked" when the object
is currently not locked
Change-Id: I2642e39393ee6472b05e4a98a1f6600f75912531
---
cmk/gui/plugins/wato/builtin_attributes.py | 35 ++++++++++++++++++++----------
cmk/gui/plugins/wato/utils/__init__.py | 2 +-
cmk/gui/watolib/host_attributes.py | 4 ++--
3 files changed, 26 insertions(+), 15 deletions(-)
diff --git a/cmk/gui/plugins/wato/builtin_attributes.py b/cmk/gui/plugins/wato/builtin_attributes.py
index be3a7c3..76d39f5 100644
--- a/cmk/gui/plugins/wato/builtin_attributes.py
+++ b/cmk/gui/plugins/wato/builtin_attributes.py
@@ -734,23 +734,33 @@ class HostAttributeLockedBy(ABCHostAttributeValueSpec):
def valuespec(self):
return Transform(
- Tuple(
- orientation="horizontal",
- title_br=False,
- elements=[
- SiteChoice(),
- ID(title=_("Program"),),
- ID(title=_("Connection ID"),),
- ],
- title=_("Locked by"),
- help=_("The host is (partially) managed by an automatic data source like the "
- "Dynamic Configuration."),
- ),
+ LockedByValuespec(),
forth=tuple,
back=list,
)
+class LockedByValuespec(Tuple):
+ def __init__(self):
+ super(LockedByValuespec, self).__init__(
+ orientation="horizontal",
+ title_br=False,
+ elements=[
+ SiteChoice(),
+ ID(title=_("Program"),),
+ ID(title=_("Connection ID"),),
+ ],
+ title=_("Locked by"),
+ help=_("The host is (partially) managed by an automatic data source like the "
+ "Dynamic Configuration."),
+ )
+
+ def value_to_text(self, value):
+ if not value or not value[1] or not value[2]:
+ return _("Not locked")
+ return super(LockedByValuespec, self).value_to_text(value)
+
+
@host_attribute_registry.register
class HostAttributeLockedAttributes(ABCHostAttributeValueSpec):
def name(self):
@@ -781,4 +791,5 @@ class HostAttributeLockedAttributes(ABCHostAttributeValueSpec):
return ListOf(
DropdownChoice(choices=host_attribute_registry.get_choices),
title=_("Locked attributes"),
+ text_if_empty=_("Not locked"),
)
diff --git a/cmk/gui/plugins/wato/utils/__init__.py b/cmk/gui/plugins/wato/utils/__init__.py
index e8ff0fb..40cc792 100644
--- a/cmk/gui/plugins/wato/utils/__init__.py
+++ b/cmk/gui/plugins/wato/utils/__init__.py
@@ -1563,7 +1563,7 @@ def configure_attributes(new,
if for_what == "host_search":
is_editable = True
- if not new and not is_editable:
+ if not is_editable:
# Bug in pylint 1.9.2 https://github.com/PyCQA/pylint/issues/1984, already fixed in master.
if active: # pylint: disable=simplifiable-if-statement
force_entry = True
diff --git a/cmk/gui/watolib/host_attributes.py b/cmk/gui/watolib/host_attributes.py
index b331caa..9f1db5a 100644
--- a/cmk/gui/watolib/host_attributes.py
+++ b/cmk/gui/watolib/host_attributes.py
@@ -277,8 +277,8 @@ class ABCHostAttribute(object):
def editable(self):
# type: () -> bool
- """Whether or not this attribute can be edited after creation
- of the object"""
+ """Whether or not this attribute can be edited using the GUI.
+ This makes the attribute a read only attribute in the GUI."""
return True
def is_mandatory(self):
Module: check_mk
Branch: master
Commit: c2470545182421e43341fce6937f9a2d54b2e6e7
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c2470545182421…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Sun Feb 24 17:48:36 2019 +0100
Dropped pre 1.4.0i3 compatibility code
Change-Id: I3259ff9ba2b4880133ecc88be0fe1ebfca088a28
---
cmk/gui/watolib/activate_changes.py | 36 ++----------------------------------
1 file changed, 2 insertions(+), 34 deletions(-)
diff --git a/cmk/gui/watolib/activate_changes.py b/cmk/gui/watolib/activate_changes.py
index b67abb4..e00926e 100644
--- a/cmk/gui/watolib/activate_changes.py
+++ b/cmk/gui/watolib/activate_changes.py
@@ -28,7 +28,6 @@ import os
import shutil
import time
import multiprocessing
-import six
import cmk.utils
import cmk.utils.daemon as daemon
@@ -1058,44 +1057,13 @@ class ActivateChangesSite(multiprocessing.Process, ActivateChanges):
])
except cmk.gui.watolib.automations.MKAutomationException as e:
if "Invalid automation command: activate-changes" in "%s" % e:
- return self._call_legacy_activate_changes_automation()
+ raise MKGeneralException(
+ "Activate changes failed (%s). The version of this site may be too old.")
else:
raise
return response
- # This is needed to be able to activate the changes on legacy (pre 1.4.0i3) slave sites.
- # Sadly this is only possible by syncing the snapshot a second time.
- def _call_legacy_activate_changes_automation(self):
- site = config.site(self._site_id)
-
- url = html.makeuri_contextless(
- [
- ("command", "push-snapshot"),
- ("secret", site["secret"]),
- ("siteid", site["id"]),
- ("mode", "slave"),
- ("restart", "yes"),
- ("debug", config.debug and "1" or ""),
- ],
- filename=site["multisiteurl"] + "automation.py",
- )
-
- response_text = self._upload_file(url, site.get('insecure', False))
-
- try:
- cmk_configuration_warnings = ast.literal_eval(response_text)
-
- # In case of an exception it returns a str/unicode message. Wrap the
- # message in a list to be compatible to regular response
- if isinstance(cmk_configuration_warnings, six.string_types):
- cmk_configuration_warnings = [cmk_configuration_warnings]
-
- return {"check_mk": cmk_configuration_warnings}
- except:
- raise cmk.gui.watolib.automations.MKAutomationException(
- _("Garbled automation response from site %s: '%s'") % (site["id"], response_text))
-
def _get_domains_needing_activation(self):
domains = set([])
for change in self._site_changes:
Module: check_mk
Branch: master
Commit: f931024b551396e088280d842a993ab1d0a21c9f
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f931024b551396…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Sun Feb 24 17:38:35 2019 +0100
Improve discovery error message "host does not exist"
The service discovery may fail for several reasons, when performed
for remote sites. For example when a host has just been created and
could not be synchronized to the remote site before starting the
discovery. The errpr message for this situation has been improved.
Change-Id: Ife9be378af6026fc1bd2b2b532f407109ca8a6a8
---
cmk/gui/wato/pages/services.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/cmk/gui/wato/pages/services.py b/cmk/gui/wato/pages/services.py
index bd0efac..e625cec 100644
--- a/cmk/gui/wato/pages/services.py
+++ b/cmk/gui/wato/pages/services.py
@@ -334,7 +334,11 @@ class AutomationServiceDiscoveryJob(AutomationCommand):
raise MKGeneralException(_("Host is missing"))
host = watolib.Host.host(host_name)
if host is None:
- raise MKGeneralException(_("Host does not exist"))
+ raise MKGeneralException(
+ _("Host %s does not exist on remote site %s. This "
+ "may be caused by a failed configuration synchronization. Have a look at "
+ "the <a href=\"wato.py?folder=&mode=changelog\">activate changes page</a> "
+ "for further information."))
host.need_permission("read")
options = json.loads(html.get_ascii_input("options"))
Module: check_mk
Branch: master
Commit: 52419c2ac66e96b31d621b0ee9ce17e7f4e7c83c
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=52419c2ac66e96…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Tue Feb 26 18:45:43 2019 +0100
Fixed nonsense types.
Change-Id: I740fe38954a36f0e8946fb03d5757f6b04424f34
---
livestatus/src/LogCache.cc | 15 +++++----------
livestatus/src/LogCache.h | 4 ++--
2 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/livestatus/src/LogCache.cc b/livestatus/src/LogCache.cc
index 9ca69ab..8822c92 100644
--- a/livestatus/src/LogCache.cc
+++ b/livestatus/src/LogCache.cc
@@ -114,8 +114,7 @@ void LogCache::addToIndex(std::unique_ptr<Logfile> logfile) {
not the messages that just has been loaded.
*/
void LogCache::logLineHasBeenAdded(Logfile *logfile, unsigned logclasses) {
- if (static_cast<unsigned long>(++_num_cached_log_messages) <=
- _max_cached_messages) {
+ if (++_num_cached_log_messages <= _max_cached_messages) {
return; // current message count still allowed, everything ok
}
@@ -125,8 +124,7 @@ void LogCache::logLineHasBeenAdded(Logfile *logfile, unsigned logclasses) {
memory can be freed. We do this by suppressing the check when
the number of messages loaded into memory has not grown
by at least check_mem_cycle messages */
- if (static_cast<unsigned long>(_num_cached_log_messages) <
- _num_at_last_check + check_mem_cycle) {
+ if (_num_cached_log_messages < _num_at_last_check + check_mem_cycle) {
return; // Do not check this time
}
@@ -141,8 +139,7 @@ void LogCache::logLineHasBeenAdded(Logfile *logfile, unsigned logclasses) {
if (it->second->size() > 0) {
_num_cached_log_messages -= it->second->size();
it->second->flush(); // drop all messages of that file
- if (static_cast<unsigned long>(_num_cached_log_messages) <=
- _max_cached_messages) {
+ if (_num_cached_log_messages <= _max_cached_messages) {
// remember the number of log messages in cache when
// the last memory-release was done. No further
// release-check shall be done until that number changes.
@@ -167,8 +164,7 @@ void LogCache::logLineHasBeenAdded(Logfile *logfile, unsigned logclasses) {
// flush only messages not needed for current query
long freed = it->second->freeMessages(~logclasses);
_num_cached_log_messages -= freed;
- if (static_cast<unsigned long>(_num_cached_log_messages) <=
- _max_cached_messages) {
+ if (_num_cached_log_messages <= _max_cached_messages) {
_num_at_last_check = _num_cached_log_messages;
return;
}
@@ -185,8 +181,7 @@ void LogCache::logLineHasBeenAdded(Logfile *logfile, unsigned logclasses) {
<< " number of entries";
_num_cached_log_messages -= it->second->size();
it->second->flush();
- if (static_cast<unsigned long>(_num_cached_log_messages) <=
- _max_cached_messages) {
+ if (_num_cached_log_messages <= _max_cached_messages) {
_num_at_last_check = _num_cached_log_messages;
return;
}
diff --git a/livestatus/src/LogCache.h b/livestatus/src/LogCache.h
index 138f4d1..5b8954e 100644
--- a/livestatus/src/LogCache.h
+++ b/livestatus/src/LogCache.h
@@ -54,8 +54,8 @@ public:
private:
MonitoringCore *const _mc;
size_t _num_cached_log_messages;
- unsigned long _max_cached_messages;
- unsigned long _num_at_last_check;
+ size_t _max_cached_messages;
+ size_t _num_at_last_check;
logfiles_t _logfiles;
std::chrono::system_clock::time_point _last_index_update;