Browse Source

initial script - list devices test

master
Julian Noble 2 years ago
parent
commit
4ab24fdf19
  1. 38
      pyscaniptonetbox.py

38
pyscaniptonetbox.py

@ -0,0 +1,38 @@
#!/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()
Loading…
Cancel
Save