Introduces a NetBox 4.6 plugin for planning rack layouts (RackConcept, ConceptDevice) without creating real dcim.Rack/dcim.Device objects, so blueprints never appear in rack/device lists, utilization reports, or IPAM. Features: - Copy paths: real rack -> concept, concept -> concept (clone), and concept -> one or more real racks (deploy, with name patterning and dry-run support) - Manual concept creation via a dedicated "Rack Concepts" nav menu - Tenant and tenant group assignment on concepts and planned devices - Partial-width device placement (1/1-1/4) with slot-based collision detection, matching netbox_utilities' partial-width feature - Custom drag-and-drop elevation (netbox-reorder-rack operates on real Device querysets, which concepts don't have) with server-side validation of every move - Full REST API, filtering, CSV import, bulk edit, search integration - Optional, config-driven interop with netbox_utilities (partial-width field mapping) and netbox-reorder-rack, degrading gracefully when either plugin is absent Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
from django.conf import settings
|
|
|
|
from netbox.plugins import PluginTemplateExtension
|
|
|
|
from .models import RackConcept
|
|
|
|
|
|
def _enabled():
|
|
return settings.PLUGINS_CONFIG.get('netbox_rack_concept', {}).get('enable_rack_tab', True)
|
|
|
|
|
|
class RackConceptButtons(PluginTemplateExtension):
|
|
"""Adds "Copy to concept" to the button row of a rack, and lists derived concepts."""
|
|
models = ['dcim.rack']
|
|
|
|
def buttons(self):
|
|
if not _enabled():
|
|
return ''
|
|
if not self.context['request'].user.has_perm('netbox_rack_concept.add_rackconcept'):
|
|
return ''
|
|
return self.render('netbox_rack_concept/inc/rack_copy_button.html', extra_context={
|
|
'rack': self.context['object'],
|
|
})
|
|
|
|
def right_page(self):
|
|
if not _enabled():
|
|
return ''
|
|
rack = self.context['object']
|
|
concepts = RackConcept.objects.restrict(self.context['request'].user, 'view').filter(source_rack=rack)
|
|
if not concepts:
|
|
return ''
|
|
return self.render('netbox_rack_concept/inc/rack_concepts_panel.html', extra_context={
|
|
'concepts': concepts,
|
|
})
|
|
|
|
|
|
template_extensions = [RackConceptButtons]
|