I have worked with NetBox for over five years now, and NetBox plugins feature has existed since version 2.8 in April 2020, but it was only recently that I got a need to start leveraging plugins to extend the NetBox functionalities. Most of the publicly available plugins work with Django model-based data that is saved […]
Tag: netbox
Configuring Logging in NetBox
Creating the log file and setting the permissions: $ sudo mkdir /var/log/netbox $ sudo touch /var/log/netbox/netbox.log $ sudo chown -R netbox.netbox /var/log/netbox $ Configuring NetBox (in /opt/netbox/netbox/netbox/configuration.py): You can set the level for the loggers as needed, in this setup the file handler accepts DEBUG and higher but the actual loggers (“django” and “netbox”) only […]
Selecting Pynetbox Version
If you have: And you need: Then you need to use: Because: NetBox 3.7.0 or newer VPNs pynetbox 7.3.3 or newer vpn app was added in pynetbox NetBox 3.5.0 or newer ASN ranges pynetbox 7.1.0 or newer asn_ranges.available_asns was added in pynetbox NetBox 3.3.0 or newer Cable terminations pynetbox 7.0.0 or newer Cable terminations were […]
Using Tags with Pynetbox in NetBox 2.9+
I wrote earlier about using tags with pynetbox in NetBox 2.8. After that in NetBox 2.9 tag handling was significantly changed: tags must now be separately created before they can be assigned to objects. Previously tags were automatically created if you assigned a nonexisting tag to an object. Another change is that when returning objects […]
Systemd Setup for FastAPI Webhook Listener
In my previous post I showed a simple NetBox webhook listener using FastAPI. In this post I’ll show the configurations to run the API using systemd. Let’s get into it, on my Debian 10 system. Let’s save the webhook_listener.py from the previous post in the same folder (webhook). Now we can try starting the webhook […]
Webhook Listener with FastAPI
Last year I wrote a webhook listener using Flask-RESTPlus. Now I wrote the same using FastAPI: There is so much to unpack there! Some of the FastAPI features I used (there are some links to FastAPI documentation): Request validation: I defined my own WebhookData class that defines the expected data in the webhook request. For […]
Timeout and Self-signed CA Handling in Pynetbox 5.x
Since pynetbox 5.0 it is possible to set the HTTP request connect timeout in your pynetbox.Api instance. Actually, it is not just a timeout value but you can instantiate a full requests.Session() object to customize the HTTP calls. As a side effect, since the SSL/TLS certificate checking parameter can also be set in the session […]
Hints for Pynetbox
Note: I don’t yet have extensive experience on NetBox 2.9.x but these have been shown useful in earlier NetBox versions. I’ll update the page later if I find some further comments about the performance in NetBox 2.9.x. Speeding up fetching the devices Fetching lots of devices (hundreds or thousands, depending on the environment) with netbox.dcim.devices.all() […]
Using Pynetbox
Pynetbox is a Python API client library for NetBox. Here are some basic examples of using pynetbox. In this page: Getting started Creating and changing something Retrieving objects Deleting objects Handling object status Using tags Referring to other objects Here we assume that you already have NetBox running (I have NetBox 2.8.6 in this demo), […]
NetBox Database Backup
A short memo how to backup any PostgreSQL database: In .pgpass (you should keep this file protected): netbox-db-backup.sh: That will also find and delete backup files older than MAXDAYS.