Module: check_mk
Branch: master
Commit: b0674e2db0e72bc0b1799abdc3d59b0fe73f9499
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b0674e2db0e72b…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Jun 8 21:08:55 2011 +0200
WATO: cleanup of IPAddressAttribute
---
web/htdocs/wato.py | 10 ++++------
web/plugins/wato/builtin_attributes.py | 3 ++-
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 3f27d41..ad4dcd7 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -2329,8 +2329,9 @@ class TextAttribute(Attribute):
class IPAddressAttribute(TextAttribute):
- def __init__(self, name, title, help = None):
- TextAttribute.__init__(self, name, title, help, "", mandatory = True)
+ def __init__(self, name, title, help = None, mandatory = False, dnslookup = False):
+ TextAttribute.__init__(self, name, title, help, "", mandatory =
mandatory)
+ self._dnslookup = dnslookup
def render_input(self, value):
if value == None:
@@ -2354,9 +2355,6 @@ class IPAddressAttribute(TextAttribute):
tdclass = 'dnserror'
return ip, tdclass, text
- def is_mandatory(self):
- return True # empty value allowed, but missing not
-
def paint(self, value, hostname):
if value == None:
ip, tdclass, text = self.do_dns(hostname)
@@ -2366,7 +2364,7 @@ class IPAddressAttribute(TextAttribute):
def validate_input(self):
value = self.from_html_vars()
- if not value: # empty -> use DNS
+ if not value and self._dnslookup: # empty -> use DNS
hostname = html.var("host")
ip, text, tdclass = self.do_dns(hostname)
if not ip:
diff --git a/web/plugins/wato/builtin_attributes.py
b/web/plugins/wato/builtin_attributes.py
index 88b5856..5c6945f 100644
--- a/web/plugins/wato/builtin_attributes.py
+++ b/web/plugins/wato/builtin_attributes.py
@@ -31,6 +31,7 @@ declare_host_attribute(TextAttribute("alias",
_("Alias"),
declare_host_attribute(IPAddressAttribute("ipaddress", _("IP
Address"),
_("IP Address of the host. Leave emtpy to use automatic
"
"hostname lookup. Enter a hostname to use dynamic
resoluting "
- "during the actual monitoring.")), True, False)
+ "during the actual monitoring."), mandatory=True,
dnslookup=True),
+ show_in_table=True, show_in_folder=True)