summaryrefslogtreecommitdiff
path: root/python/vyos
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-12-06 19:32:09 +0100
committerChristian Poessinger <christian@poessinger.com>2019-12-06 19:32:17 +0100
commit3a16fb46a16f91557f6805e74aafb568f46fd1c0 (patch)
tree3a7e289c6d55997f22ac076a762eeaa9dd8c9392 /python/vyos
parent242251ea50f1d26127effc140933cbdb1149a206 (diff)
downloadvyos-1x-3a16fb46a16f91557f6805e74aafb568f46fd1c0.tar.gz
vyos-1x-3a16fb46a16f91557f6805e74aafb568f46fd1c0.zip
Python/VyOS validate: T1849: handle is_ipv6()/is_ipv6() exceptions
Diffstat (limited to 'python/vyos')
-rw-r--r--python/vyos/validate.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/python/vyos/validate.py b/python/vyos/validate.py
index 258f7f76a..3f3166022 100644
--- a/python/vyos/validate.py
+++ b/python/vyos/validate.py
@@ -29,10 +29,13 @@ def is_ipv4(addr):
# With the below statement we can check for IPv4 networks and host
# addresses at the same time
- if ipaddress.ip_address(addr.split(r'/')[0]).version == 4:
- return True
- else:
- return False
+ try:
+ if ipaddress.ip_address(addr.split(r'/')[0]).version == 4:
+ return True
+ except:
+ pass
+
+ return False
def is_ipv6(addr):
"""
@@ -41,10 +44,13 @@ def is_ipv6(addr):
# With the below statement we can check for IPv4 networks and host
# addresses at the same time
- if ipaddress.ip_network(addr.split(r'/')[0]).version == 6:
- return True
- else:
- return False
+ try:
+ if ipaddress.ip_network(addr.split(r'/')[0]).version == 6:
+ return True
+ except:
+ pass
+
+ return False
def is_intf_addr_assigned(intf, addr):
"""