Module: check_mk
Branch: master
Commit: 7203a2540c26d9e171cdce74f3814e365adea6d1
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7203a2540c26d9…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Apr 16 15:52:42 2013 +0200
piggyback: new translation that simply drops the domain
---
modules/check_mk_base.py | 8 ++++++--
web/plugins/wato/check_mk_configuration.py | 6 ++++++
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index b3dd7e2..0cae94f 100755
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -498,7 +498,11 @@ def translate_piggyback_host(sourcehost, backedhost):
elif caseconf == "lower":
backedhost = backedhost.lower()
- # 2. Regular expression conversion
+ # 2. Drop domain part
+ if translation.get("drop_domain"):
+ backedhost = backedhost.split(".", 1)[0]
+
+ # 3. Regular expression conversion
if "regex" in translation:
regex, subst = translation.get("regex")
if not regex.endswith('$'):
@@ -510,7 +514,7 @@ def translate_piggyback_host(sourcehost, backedhost):
for nr, text in enumerate(mo.groups()):
backedhost = backedhost.replace("\\%d" % (nr+1), text)
- # 3. Explicity mapping
+ # 4. Explicity mapping
for from_host, to_host in translation.get("mapping", []):
if from_host == backedhost:
backedhost = to_host
diff --git a/web/plugins/wato/check_mk_configuration.py
b/web/plugins/wato/check_mk_configuration.py
index 59826fa..788b5fe 100644
--- a/web/plugins/wato/check_mk_configuration.py
+++ b/web/plugins/wato/check_mk_configuration.py
@@ -1686,6 +1686,12 @@ register_rule(group,
( "lower", _("Convert hostnames to lower
case") ),
]
)),
+ ( "drop_domain",
+ FixedValue(
+ True,
+ title = _("Convert FQHN"),
+ totext = _("Drop domain part
(<tt>host123.foobar.de</tt> → <tt>host123</tt>)"),
+ )),
( "regex",
Tuple(
title = _("Regular expression substitution"),