From 4ab24fdf1955ce29065a070ad076ab3ee69c06ab Mon Sep 17 00:00:00 2001 From: Julian Noble Date: Wed, 17 Aug 2022 23:20:20 +1000 Subject: [PATCH] initial script - list devices test --- pyscaniptonetbox.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 pyscaniptonetbox.py diff --git a/pyscaniptonetbox.py b/pyscaniptonetbox.py new file mode 100644 index 0000000..141dc87 --- /dev/null +++ b/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() + + + +