Kani999 / netbox-attachments

Plugin to manage attachments for any model
Apache License 2.0
55 stars 4 forks source link
attachments netbox netbox-plugin

NetBox Attachments Plugin

NetBox plugin for attaching files to any model.

Features

This plugin provides the following model:

Compatibility

The following table shows the compatibility between different NetBox versions and plugin versions:

NetBox Version Plugin Version
>= 3.3.4 0.0.0 - 0.0.5
>= 3.4.0 0.0.6 - 1.0.6
>= 3.4.3 1.0.7 - 1.1.x
>= 3.5.0 2.0.0
>= 3.6.0 3.0.0
>= 3.7.0 4.0.0
>= 4.0.0 5.x.x
>= 4.1.0 6.x.x

Installation

The plugin is available as a Python package on PyPI and can be installed with pip:

pip install netbox-attachments

To enable the plugin, add it to the PLUGINS list in your configuration.py:

PLUGINS = ['netbox_attachments']

Next, create a directory for storing attachments and set the appropriate permissions:

mkdir -p /opt/netbox/netbox/media/netbox-attachments
chown netbox /opt/netbox/netbox/media/netbox-attachments

Run the database migrations for the plugin:

python3 manage.py migrate netbox_attachments

Restart NetBox and ensure that netbox-attachments is included in your local_requirements.txt.

For more details, see the NetBox Documentation.

Configuration

Plugin Options

The plugin can be customized using the following configuration options:

Warning: The additional_tab option does not work for plugin models.

Configuration Example

Here is an example of how to configure the plugin in configuration.py:

PLUGINS_CONFIG = {
    'netbox_attachments': {
        'apps': ['dcim', 'ipam', 'circuits', 'tenancy', 'virtualization', 'wireless', 'inventory_monitor'],
        'display_default': "right_page",
        'display_setting': {
            'ipam.vlan': "left_page",
            'dcim.device': "full_width_page",
            'dcim.devicerole': "full_width_page",
            'inventory_monitor.probe': "additional_tab"
        }
    }
}

Enabling Attachments for Custom Plugins (Models)

To enable attachments for custom plugin models:

  1. Append your plugin to the apps configuration list:

    apps: ['<plugin_name>']
  2. Extend the detail templates of your plugin models:

    {% load plugins %}  # At the top of the template
    
    {% plugin_right_page object %}  # Under the comments section
    
    # Add left_page and full_width for future extensions

Example (Device Model)

Screenshots