Module: check_mk
Branch: master
Commit: 04c399c1431431b26907191825c30e41a02b29a9
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=04c399c1431431…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Jul 29 09:51:39 2011 +0200
WATO: add helper function for checking ip address
---
web/htdocs/wato.py | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index a1ea3ab..be5b457 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -2566,6 +2566,18 @@ class IPAddressAttribute(TextAttribute):
return value.lower().startswith(crit.lower().strip("*"))
+# Helper function for checking if an ip address is valid
+def is_valid_ip_address(ip):
+ try:
+ parts = ip.split('.')
+ if len(parts) != 4:
+ raise Exception()
+ for x in parts:
+ if int(x) < 0 or int(x) > 255:
+ raise Exception()
+ except:
+ return False
+ return True
# A text attribute that is stored in a Nagios custom macro
class NagiosTextAttribute(TextAttribute):