Files
NetBox-Concept/netbox_rack_concept/__init__.py
T
MrBlakeandClaude Opus 5.5 6ffe6348a6 Fix partial-width integration with Netbox-Utilities
The default mapping pointed to netbox_utilities.RackDevicePosition / width_fraction, which never existed, so partial widths were silently ignored: copying a rack lost them and deploying a concept with devices sharing a rack unit failed with "already occupied".

Use netbox_utilities.DeviceRackPlacement (width, horizontal_position), convert between 0-based concept positions and the 1-based positions of netbox_utilities, and stage the width on the device before full_clean() so the Utilities collision check sees it. Configurations with the old model name are migrated automatically.

Verified on NetBox 4.7.2: copying a rack with two half-width devices in one U and deploying it twice recreates both side by side. Bump version to 0.2.6.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-13 15:25:24 +02:00

57 lines
2.2 KiB
Python

from netbox.plugins import PluginConfig
__version__ = '0.2.6'
class RackConceptConfig(PluginConfig):
name = 'netbox_rack_concept'
verbose_name = 'NetBox Rack Concepts'
description = 'Rack blueprints: plan racks and their equipment without creating real racks or devices'
version = __version__
author = 'Claude'
base_url = 'rack-concepts'
min_version = '4.6.0'
# Verified against the real 4.7.1 source: RackBase/Rack fields, PortTemplateMapping,
# Cable/CableTermination, register_model_view/ViewTab, NetBoxModel*, ChoiceSet
# (its CHOICES refactor explicitly keeps supporting the legacy (value, label, color)
# tuple format this plugin uses) are all unchanged or additive. No 4.8 exists yet to
# verify against, so the ceiling stops at the 4.7 line rather than guessing further.
max_version = '4.7.99'
# These paths are relative to this module (NetBox prepends self.__module__),
# so they must NOT be prefixed with 'netbox_rack_concept.' again.
menu = 'navigation.menu'
template_extensions = 'template_content.template_extensions'
default_settings = {
# Defaults used when a concept is created from scratch.
'default_u_height': 42,
'default_width': 19,
# Show the "Copy to concept" button on the dcim.Rack detail page.
'enable_rack_tab': True,
# Status assigned to the objects created when a concept is deployed.
'deployed_rack_status': 'planned',
'deployed_device_status': 'planned',
# Mapping onto the partial-width implementation of netbox_utilities.
# Adjust these if that plugin renames its fields; set 'enabled' to False
# to never write partial-width data during deployment.
'partial_width': {
'enabled': True,
'model': 'netbox_utilities.DeviceRackPlacement',
'device_field': 'device',
'fraction_field': 'width',
'position_field': 'horizontal_position',
# netbox_utilities counts positions from 1 (left); concepts count from 0.
'position_base': 1,
},
}
def ready(self):
super().ready()
from . import search # noqa: F401
config = RackConceptConfig