Basic python script to scan a range of IP addresses and add them to netbox
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
770 B

#!/usr/bin/env python3
import sys
import yaml
from pathlib import Path
import networkscan
import requests
import pynetbox
def get_settings():
full_file_path = Path(__file__).parent.joinpath('local_settings.yaml')
with open(full_file_path) as settings:
settings_data = yaml.safe_load(settings)
return settings_data
settings = get_settings()
nb_url = settings['netbox']['url']
nb_token = settings['netbox']['auth_token']
print("Netbox server: " + nb_url)
print("Netbox token: " + nb_token)
nb = pynetbox.api(nb_url,token=nb_token)
print("version: -" + nb.version + "-")
#print(nb.dcim.devices.all())
devices = nb.dcim.devices.all()
for i in devices:
print(i)
#for device in devices:
#print('test')
#print(device.name)
sys.exit()