Skip to content

About

A NetBox plugin that subdivides device bay rectangles in rack elevation SVGs to show per-bay labels, role colors, and clickable links to child devices.

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

netbox-render

netbox-render

A NetBox plugin I wrote to fix a visibility gap in rack elevations: devices with device bays render as a single opaque block, hiding what's actually installed. This plugin subdivides that block into labeled, color-coded, clickable sections — one per bay.

What it does

Out of the box, NetBox shows a device-bay device as one rectangle with an occupancy count like "3/4". To see what's installed, you have to click into the parent and check the Device Bays tab.

I patched RackElevationSVG._draw_device so each bay gets its own section showing:

  • Bay index (1, 2, 3, ...) sorted by bay name
  • Child device name with text wrapping for long names, or "(empty)"
  • Role color on the front face (rear renders grey, matching stock behavior)
  • If you Device tpyes have front and/or rear images attached, it will render images instead of color
  • Clickable link to the child device page
  • Optional device type images with label overlay (enable_images)
  • Auto grid layout for dense shelves (multiple bays arranged in columns)

Devices without bays are untouched.

Before and after

Without plugin - Front Without plugin - Rear With plugin - Front With plugin - Rear
Stock NetBox elevation With netbox-render With netbox-render With netbox-render
Single opaque block Single opaque block Subdivided with bay labels and role colors Subdivided with bay labels and role colors

Bay ordering

Bays sort alphabetically by name — there's no numeric position field in NetBox's device bay model. Name them "Slot 01", "Slot 02", etc. for predictable ordering.

Compatibility

NetBox Plugin Status
4.6.0 - 4.6.5 0.2.1 Tested

Installation

  1. Add netbox-render to local_requirements.txt

    echo "netbox-render" >> local_requirements.txt
  2. Install Plugin

    pip install netbox-render
  3. Add to configuration.py:

    PLUGINS = ['netbox_render']
  4. Restart NetBox:

    sudo systemctl restart netbox netbox-rq

For development:

  1. Local install

    pip install -e .

Configuration

Auto-calculated layout rendering

PLUGINS_CONFIG = {
    'netbox_render': {
        'enable_images': True,       # default: False
        'layouts': {},               # default: {} (auto-calculate) 
    },
}

Custom device-slug defined layout rendering

PLUGINS_CONFIG = {
    'netbox_render': {
        'enable_images': True,       # default: False
        'layouts': {                  # default: {} (auto-calculate)
            'mac-mini-shelf-2u': {'columns': 3},
            'rpi-cluster-2u': {'columns': 5},
        },
    },
}
Key Default Description
enable_images False Show device type front/rear images in bay sections
layouts {} Per-device-type grid layout overrides (key = device type slug)

Grid layout

The plugin auto-calculates the optimal column count by minimizing cell aspect ratio. When layouts tie (e.g. 2×2 vs 4×1), it prefers fewer empty cells and more columns — so typical shelves auto-detect a horizontal row while tall chassis devices stack vertically.

Override with layouts using the device type slug as the key and {'columns': N} as the value. Invalid values (zero, non-integer, exceeding bay count) fall back to auto-calculation with a logged warning.

See the shelf devices guide for detailed examples.

Shelf device guide

See Shelf-devices Guide for a walkthrough on modeling rack shelves using device bays and how this plugin renders them.

Known limitations

  • Bay ordering is name-based, not positional — no way around this without modifying NetBox's data model
  • Images off by default
  • Rear face always renders grey (matches stock NetBox)
  • Both faces show the same bay breakdown
  • No migrations, no DB changes — rendering only
  • Monkeypatch approach: I patch an internal method, so test after every NetBox upgrade

Support

License

Apache-2.0

About

A NetBox plugin that subdivides device bay rectangles in rack elevation SVGs to show per-bay labels, role colors, and clickable links to child devices.

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Contributors

Languages