minor changes

This commit is contained in:
José Lopes 2018-09-26 15:20:36 -03:00
parent 3be564d967
commit c4a78cf5ab
3 changed files with 7 additions and 5 deletions

View File

@ -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
} }

View File

@ -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:

View File

@ -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',