mirror of
https://github.com/lopes/netbox-scanner.git
synced 2025-07-22 13:24:38 +02:00
minor changes
This commit is contained in:
parent
3be564d967
commit
c4a78cf5ab
@ -1,7 +1,7 @@
|
|||||||
# netbox-scanner configuration file.
|
# netbox-scanner configuration file.
|
||||||
|
|
||||||
NETBOX = {
|
NETBOX = {
|
||||||
'ADDRESS': '',
|
'ADDRESS': 'https://',
|
||||||
'TOKEN': '',
|
'TOKEN': '',
|
||||||
'TLS_VERIFY': True
|
'TLS_VERIFY': True
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ class NetBoxScanner(object):
|
|||||||
self.unknown = unknown
|
self.unknown = unknown
|
||||||
|
|
||||||
def get_description(self, name, cpe):
|
def get_description(self, name, cpe):
|
||||||
|
'''Define a description based on hostname and CPE'''
|
||||||
if name:
|
if name:
|
||||||
return name
|
return name
|
||||||
else:
|
else:
|
||||||
@ -22,6 +23,7 @@ class NetBoxScanner(object):
|
|||||||
c.get_product()[0], c.get_version()[0])
|
c.get_product()[0], c.get_version()[0])
|
||||||
|
|
||||||
def nbhandler(self, command, **kwargs):
|
def nbhandler(self, command, **kwargs):
|
||||||
|
'''Handles NetBox integration'''
|
||||||
if command == 'get':
|
if command == 'get':
|
||||||
return self.netbox.ipam.ip_addresses.get(
|
return self.netbox.ipam.ip_addresses.get(
|
||||||
address=kwargs['address'])
|
address=kwargs['address'])
|
||||||
@ -41,7 +43,7 @@ class NetBoxScanner(object):
|
|||||||
|
|
||||||
:param network: a valid network, like 10.0.0.0/8
|
:param network: a valid network, like 10.0.0.0/8
|
||||||
:return: a list with dictionaries of responsive
|
:return: a list with dictionaries of responsive
|
||||||
hosts (addr and description)
|
hosts (address and description)
|
||||||
'''
|
'''
|
||||||
hosts = []
|
hosts = []
|
||||||
nm = PortScanner()
|
nm = PortScanner()
|
||||||
@ -62,7 +64,7 @@ class NetBoxScanner(object):
|
|||||||
'''Scan some networks and sync them to NetBox.
|
'''Scan some networks and sync them to NetBox.
|
||||||
|
|
||||||
:param networks: a list of valid networks, like ['10.0.0.0/8']
|
:param networks: a list of valid networks, like ['10.0.0.0/8']
|
||||||
:return: nothing will be returned
|
:return: synching statistics are returned as a tuple
|
||||||
'''
|
'''
|
||||||
create = update = delete = undiscovered = duplicate = 0
|
create = update = delete = undiscovered = duplicate = 0
|
||||||
for net in networks:
|
for net in networks:
|
||||||
@ -103,7 +105,7 @@ class NetBoxScanner(object):
|
|||||||
self.nbhandler('delete', nbhost=nbhost)
|
self.nbhandler('delete', nbhost=nbhost)
|
||||||
delete += 1
|
delete += 1
|
||||||
else:
|
else:
|
||||||
logging.info('undiscovered: {} "{}"'.format(
|
logging.warning('undiscovered: {} "{}"'.format(
|
||||||
nbhost.address, nbhost.description))
|
nbhost.address, nbhost.description))
|
||||||
undiscovered += 1
|
undiscovered += 1
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
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.3.1',
|
version='0.3.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