Fix ip_allocation module for netaddr-0.7.5
There is a bug that prevents checking whether an IP in string form is in an IPNetwork. Explicitly convert the string to an IPAddress to workaround this.
This commit is contained in:
parent
c3b360764a
commit
d49cdb4b84
@ -133,10 +133,12 @@ def update_allocation(module, allocations):
|
|||||||
object_name = "%s_ips" % net_name
|
object_name = "%s_ips" % net_name
|
||||||
net_allocations = allocations.setdefault(object_name, {})
|
net_allocations = allocations.setdefault(object_name, {})
|
||||||
invalid_allocations = {hn: ip for hn, ip in net_allocations.items()
|
invalid_allocations = {hn: ip for hn, ip in net_allocations.items()
|
||||||
if ip not in network}
|
if netaddr.IPAddress(ip) not in network}
|
||||||
if invalid_allocations:
|
if invalid_allocations:
|
||||||
module.fail_json(msg="Found invalid existing allocations in network %s: %s" %
|
module.fail_json(msg="Found invalid existing allocations in network %s: %s" %
|
||||||
(network, ", ".join("%s: %s" % (hn, ip) for hn, ip in invalid_allocations.items())))
|
(network,
|
||||||
|
", ".join("%s: %s" % (hn, ip)
|
||||||
|
for hn, ip in invalid_allocations.items())))
|
||||||
if hostname not in net_allocations:
|
if hostname not in net_allocations:
|
||||||
result['changed'] = True
|
result['changed'] = True
|
||||||
allocated_ips = netaddr.IPSet(net_allocations.values())
|
allocated_ips = netaddr.IPSet(net_allocations.values())
|
||||||
|
Loading…
Reference in New Issue
Block a user