ip to net address conversions

This commit is contained in:
Daan Hoogland 2021-03-10 17:01:35 +01:00
parent 08627659f6
commit 004cd05896
3 changed files with 7 additions and 3 deletions

View File

@ -149,7 +149,9 @@ class CsInterface:
def ip_in_subnet(self, ip):
ipo = ip_address(ip)
net = ip_network("%s/%s" % (self.get_ip(), self.get_size()))
# we are using an ip as netaddress so strict must be False
net = ip_network("%s/%s" % (self.get_ip(), self.get_size()),
strict=False)
return ipo in net
def get_gateway_cidr(self):

View File

@ -119,7 +119,7 @@ def get_device_info():
to = {}
to['ip'] = vals[1]
to['dev'] = vals[-1]
to['network'] = ip_network(to['ip'])
to['network'] = ip_network(to['ip'], strict=False)
to['dnsmasq'] = False
list.append(to)
return list

View File

@ -42,7 +42,9 @@ def merge(dbag, ip):
nic_dev_id = address['nic_dev_id']
dbag[dev].remove(address)
ipo = ip_network(ip['public_ip'] + '/' + ip['netmask'])
# we are passing and must allow for host bits so strict is False
ipo = ip_network(ip['public_ip'] + '/' + ip['netmask'],
strict=False)
if 'nic_dev_id' in ip:
nic_dev_id = ip['nic_dev_id']
if 'vif_mac_address' in ip: