Merge pull request #5 from roterschnee/master

Check for existing IP´s in netbox in sync_network
This commit is contained in:
José Lopes 2019-05-13 23:53:06 -03:00 committed by GitHub
commit 02d573d4fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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)