bugfix on deletion routine

This commit is contained in:
José Lopes 2018-10-01 17:27:17 -03:00
parent 7ba9116d3e
commit 44b2cd7a10
3 changed files with 5 additions and 5 deletions

View File

@ -6,7 +6,7 @@ A scanner util for NetBox, because certain networks can be updated automagically
$ pip3 install netbox-scanner
Another way is download from GitHub:
Another way is to download from GitHub:
$ wget https://github.com/forkd/netbox-scanner/archive/master.zip
$ unzip netbox-scanner-master.zip -d netbox-scanner
@ -30,7 +30,7 @@ Note that `netbox-scanner` will require Nmap and an instance of NetBox ready to
2. If host is not in NetBox, it'll be created.
3. It will iterate through each network to find and delete any hosts registered in NetBox that did not respond to scan, and have the tag `netbox-scanner/config.py/TAG`.
This way, if some hosts in your monitored networks are eventually down, but you don't want to delete them, just make sure that they doesn't have the `netbox-scanner/config.py/TAG` tag.
This way, if some hosts in your monitored networks are eventually down, but you don't want to delete them, just make sure that they doesn't have the tag defined in `netbox-scanner/config.py/TAG`.
To see a list of all available parameters in `netbox-scanner.py`, simple use the `-h` option --please note that all parameters are optional, because all of them can be set using `netbox-scanner/config.py` file:

View File

@ -119,8 +119,8 @@ class NetBoxScanner(object):
for ipv4 in IPv4Network(net):
address = str(ipv4)
if not any(h['address'] == address for h in hosts):
nbhost = self.nbhandler('get', address=address)
try:
nbhost = self.nbhandler('get', address=address)
if self.tag in nbhost.tags:
logging.warning('delete: {} "{}"'.format(
nbhost.address, nbhost.description))
@ -130,6 +130,6 @@ class NetBoxScanner(object):
logging.warning('undiscovered: {} "{}"'.format(
nbhost.address, nbhost.description))
undiscovered += 1
except AttributeError:
except (AttributeError, ValueError):
pass
return (create, update, delete, undiscovered, duplicate)

View File

@ -7,7 +7,7 @@ with open('README.md', 'r') as fh:
setuptools.setup(
name='netbox-scanner',
version='0.4.1',
version='0.4.2',
author='José Lopes de Oliveira Jr.',
author_email='jlojunior@gmail.com',
description='A scanner util for NetBox',