This section entails features of NetBox which are not crucial to its primary functions, but that provide additional value.
[TOC]
NetBox allows users to define custom templates that can be used when exporting objects. To create an export template, navigate to Extras > Export Templates under the admin interface.
Each export template is associated with a certain type of object. For instance, if you create an export template for VLANs, your custom template will appear under the "Export" button on the VLANs list.
Export templates are written in Django's template language, which is very similar to Jinja2. The list of objects returned from the database is stored in the queryset
variable. Typically, you'll want to iterate through this list using a for loop.
A MIME type and file extension can optionally be defined for each export template. The default MIME type is text/plain
.
Here's an example device export template that will generate a simple Nagios configuration from a list of devices.
{% for d in queryset %}{% if d.status and d.primary_ip %}define host{
use generic-switch
host_name {{ d.name }}
address {{ d.primary_ip.address.ip }}
}
{% endif %}{% endfor %}
The generated output will look something like this:
define host{
use generic-switch
host_name switch1
address 192.0.2.1
}
define host{
use generic-switch
host_name switch2
address 192.0.2.2
}
define host{
use generic-switch
host_name switch3
address 192.0.2.3
}
NetBox does not generate graphs itself. This feature allows you to embed contextual graphs from an external resources inside certain NetBox views. Each embedded graph must be defined with the following parameters:
obj
.obj
.