mirror of
https://github.com/lopes/netbox-scanner.git
synced 2025-07-23 22:04:50 +02:00
bugfix on deletion routine
This commit is contained in:
parent
7ba9116d3e
commit
44b2cd7a10
@ -6,7 +6,7 @@ A scanner util for NetBox, because certain networks can be updated automagically
|
|||||||
|
|
||||||
$ pip3 install netbox-scanner
|
$ 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
|
$ wget https://github.com/forkd/netbox-scanner/archive/master.zip
|
||||||
$ unzip netbox-scanner-master.zip -d netbox-scanner
|
$ 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.
|
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`.
|
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:
|
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:
|
||||||
|
|
||||||
|
@ -119,8 +119,8 @@ class NetBoxScanner(object):
|
|||||||
for ipv4 in IPv4Network(net):
|
for ipv4 in IPv4Network(net):
|
||||||
address = str(ipv4)
|
address = str(ipv4)
|
||||||
if not any(h['address'] == address for h in hosts):
|
if not any(h['address'] == address for h in hosts):
|
||||||
nbhost = self.nbhandler('get', address=address)
|
|
||||||
try:
|
try:
|
||||||
|
nbhost = self.nbhandler('get', address=address)
|
||||||
if self.tag in nbhost.tags:
|
if self.tag in nbhost.tags:
|
||||||
logging.warning('delete: {} "{}"'.format(
|
logging.warning('delete: {} "{}"'.format(
|
||||||
nbhost.address, nbhost.description))
|
nbhost.address, nbhost.description))
|
||||||
@ -130,6 +130,6 @@ class NetBoxScanner(object):
|
|||||||
logging.warning('undiscovered: {} "{}"'.format(
|
logging.warning('undiscovered: {} "{}"'.format(
|
||||||
nbhost.address, nbhost.description))
|
nbhost.address, nbhost.description))
|
||||||
undiscovered += 1
|
undiscovered += 1
|
||||||
except AttributeError:
|
except (AttributeError, ValueError):
|
||||||
pass
|
pass
|
||||||
return (create, update, delete, undiscovered, duplicate)
|
return (create, update, delete, undiscovered, duplicate)
|
||||||
|
2
setup.py
2
setup.py
@ -7,7 +7,7 @@ with open('README.md', 'r') as fh:
|
|||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name='netbox-scanner',
|
name='netbox-scanner',
|
||||||
version='0.4.1',
|
version='0.4.2',
|
||||||
author='José Lopes de Oliveira Jr.',
|
author='José Lopes de Oliveira Jr.',
|
||||||
author_email='jlojunior@gmail.com',
|
author_email='jlojunior@gmail.com',
|
||||||
description='A scanner util for NetBox',
|
description='A scanner util for NetBox',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user