added method to retrieve list of netbox prefixes

This commit is contained in:
José Lopes 2018-10-10 15:57:02 -03:00
parent e0da9eb354
commit 96e16e30fc
3 changed files with 12 additions and 1 deletions

View File

@ -1,3 +1,10 @@
# This script can be used sanitize the list of networks
# to be scanned. In practice, (almost) the same routine
# is executed everytime NetBoxScanner().sync() is
# called, but if you want to debug this list or even
# keep a more organized version, you can use dac.py.
##
import re import re
from config import NETWORKS from config import NETWORKS

View File

@ -42,6 +42,10 @@ class NetBoxScanner(object):
return net return net
return False return False
def get_networks(self):
'''Retrieves all networks/prefixes recorded into NetBox.'''
return [str(net) for net in self.netbox.ipam.prefixes.all()]
def get_description(self, address, name, cpe): def get_description(self, address, name, cpe):
'''Define a description based on hostname and CPE''' '''Define a description based on hostname and CPE'''
if name: if name:

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.5.5', version='0.5.6',
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',