Commit 76c74d
2024-12-30 11:07:22 Steven Anderson: init/dev/null .. ScriptFU/python/netbox.md | |
@@ 0,0 1,15 @@ | |
+ | # netbox |
+ | |
+ | #### search for devices in shell |
+ | ```py |
+ | import pynetbox |
+ | |
+ | nb = pynetbox.api('https://netboxurl>', token="<token>") |
+ | |
+ | devices = nb.dcim.devices.filter(site="<site>", tenant=["<tenant>"], status=["offline", "active"]) |
+ | |
+ | len(devices) |
+ | |
+ | for device in devices: |
+ | print(f"{device.id},{device.name}") |
+ | ``` |