Module: check_mk
Branch: master
Commit: 9651ef812e76c84da1d834ed499e93fa1b1567e3
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9651ef812e76c8…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Apr 9 15:08:25 2019 +0200
Only add service labels in case the service was found by self._get_service_info
Change-Id: Idfe18d6e83cdc50b884a72e889a4e89d78305978
---
cmk_base/automations/check_mk.py | 3 ++-
tests/integration/cmk_base/test_automations.py | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/cmk_base/automations/check_mk.py b/cmk_base/automations/check_mk.py
index 7520a73..2a7ea40 100644
--- a/cmk_base/automations/check_mk.py
+++ b/cmk_base/automations/check_mk.py
@@ -575,7 +575,8 @@ class AutomationAnalyseServices(Automation):
servicedesc = args[1].decode("utf-8")
service_info = self._get_service_info(config_cache, hostname, servicedesc)
- service_info["labels"] = config_cache.labels_of_service(hostname,
servicedesc)
+ if service_info:
+ service_info["labels"] = config_cache.labels_of_service(hostname,
servicedesc)
return service_info
# Determine the type of the check, and how the parameters are being
diff --git a/tests/integration/cmk_base/test_automations.py
b/tests/integration/cmk_base/test_automations.py
index 728f32b..6fc4dda 100644
--- a/tests/integration/cmk_base/test_automations.py
+++ b/tests/integration/cmk_base/test_automations.py
@@ -1,7 +1,8 @@
+# pylint: disable=redefined-outer-name
import re
import ast
import subprocess
-import pytest
+import pytest # type: ignore
from testlib import web, repo_path # pylint: disable=unused-import