Module: check_mk
Branch: master
Commit: 17a1373947fda31798a2e524be270b1ceeb21634
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=17a1373947fda3…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Wed May 25 14:55:29 2016 +0200
3242 FIX Fixed hostname translation for empty optional groups
---
.werks/3242 | 10 ++++++++++
ChangeLog | 1 +
modules/check_mk_base.py | 3 ++-
web/htdocs/wato.py | 3 ++-
4 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/.werks/3242 b/.werks/3242
new file mode 100644
index 0000000..1bb1b70
--- /dev/null
+++ b/.werks/3242
@@ -0,0 +1,10 @@
+Title: Fixed hostname translation for empty optional groups
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1464180857
+
+
diff --git a/ChangeLog b/ChangeLog
index 7c31a51..4f71cbf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -389,6 +389,7 @@
* 3461 FIX: Fixed exception in case manpage for non existant check is accessed
* 3527 FIX: WATO service discovery: fixed warning with locked hosts...
* 3534 FIX: Fixed exception with upload of interlaced PNG files...
+ * 3242 FIX: Fixed hostname translation for empty optional groups
Notifications:
* 3263 Notifications: allow users to restrict by their contact groups...
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index 564f0af..2327d0c 100644
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -648,10 +648,11 @@ def do_hostname_translation(translation, hostname):
if not expr.endswith('$'):
expr += '$'
rcomp = regex(expr)
+ # re.RegexObject.sub() by hand to handle non-existing references
mo = rcomp.match(hostname)
if mo:
hostname = subst
- for nr, text in enumerate(mo.groups()):
+ for nr, text in enumerate(mo.groups("")):
hostname = hostname.replace("\\%d" % (nr+1), text)
# 4. Explicity mapping
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 4a76689..b6da6a8 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -13750,10 +13750,11 @@ def do_hostname_translation(translation, hostname):
if not expr.endswith('$'):
expr += '$'
rcomp = regex(expr)
+ # re.RegexObject.sub() by hand to handle non-existing references
mo = rcomp.match(hostname)
if mo:
hostname = subst
- for nr, text in enumerate(mo.groups()):
+ for nr, text in enumerate(mo.groups("")):
hostname = hostname.replace("\\%d" % (nr+1), text)
# 4. Explicit mapping