Check for IP existence in netbox before blind deletion

This commit is contained in:
roterschnee 2019-05-13 11:41:12 +02:00
parent 867652b3b2
commit 0b03893204

View File

@ -155,8 +155,13 @@ class NetBoxScanner(object):
self.logger('scanned', net=network, hosts=len(hosts))
for host in hosts:
self.sync_host(host)
ips = list()
ips.append(self.netbox.ipam.ip_addresses.all())
for ipv4 in IPv4Network(network): # cleanup
address = str(ipv4)
if any(ip == address for ip in ips):
if not any(h[0]==address for h in hosts):
try:
nbhost = self.netbox.ipam.ip_addresses.get(address=address)