summaryrefslogtreecommitdiff
path: root/python/vyos/validate.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-06-21 17:02:30 +0200
committerChristian Poessinger <christian@poessinger.com>2021-06-21 17:03:45 +0200
commite42a5fd5f6c0580e11ec5ae1e98c8a5907103f0a (patch)
treeb45c7e6d956ae0b80b3656a343071120052a9a04 /python/vyos/validate.py
parentfa09a06efbeb905622fa9e1ac8598e50e683710d (diff)
downloadvyos-1x-e42a5fd5f6c0580e11ec5ae1e98c8a5907103f0a.tar.gz
vyos-1x-e42a5fd5f6c0580e11ec5ae1e98c8a5907103f0a.zip
Python: T3641: adjust to changes in latest vesion of netifaces library
Diffstat (limited to 'python/vyos/validate.py')
-rw-r--r--python/vyos/validate.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/python/vyos/validate.py b/python/vyos/validate.py
index 23e88b5ac..0dad2a6cb 100644
--- a/python/vyos/validate.py
+++ b/python/vyos/validate.py
@@ -49,7 +49,7 @@ def is_intf_addr_assigned(intf, addr):
return _is_intf_addr_assigned(intf, ip, mask)
return _is_intf_addr_assigned(intf, addr)
-def _is_intf_addr_assigned(intf, address, netmask=''):
+def _is_intf_addr_assigned(intf, address, netmask=None):
"""
Verify if the given IPv4/IPv6 address is assigned to specific interface.
It can check both a single IP address (e.g. 192.0.2.1 or a assigned CIDR
@@ -85,14 +85,14 @@ def _is_intf_addr_assigned(intf, address, netmask=''):
continue
# we do not have a netmask to compare against, they are the same
- if netmask == '':
+ if not netmask:
return True
prefixlen = ''
if is_ipv4(ip_addr):
prefixlen = sum([bin(int(_)).count('1') for _ in ip['netmask'].split('.')])
else:
- prefixlen = sum([bin(int(_,16)).count('1') for _ in ip['netmask'].split(':') if _])
+ prefixlen = sum([bin(int(_,16)).count('1') for _ in ip['netmask'].split('/')[0].split(':') if _])
if str(prefixlen) == netmask:
return True