Module: check_mk
Branch: master
Commit: 7539c539435509d2d285c3a3d395cefabaa64866
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7539c539435509…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Nov 11 14:54:20 2014 +0100
New valuespec for Hostname or IPv4 Address
---
web/htdocs/valuespec.py | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index 8fdec8b..4abd944 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -562,6 +562,13 @@ class IPv4Address(IPv4Network):
self.validate_ipaddress(value, varprefix)
ValueSpec.custom_validate(self, value, varprefix)
+# A host name with or without domain part. Also allow IP addresses
+class Hostname(TextAscii):
+ def __init__(self, **kwargs):
+ TextAscii.__init__(self, **kwargs)
+ self._regex = re.compile('^[-0-9a-zA-Z_.]+$')
+ self._regex_error = _("Please enter a valid hostname or IPv4
address.")
+
# Valuespec for a HTTP Url (not HTTPS), that
# automatically adds http:// to the value