Mirror device cabling 1:1 (per-type tabs) and copy cables on rack import

- Split the device detail page's single "Components" table into the
  same seven tabs a real dcim.Device has, in the same order: Console
  Ports, Console Server Ports, Power Ports, Power Outlets, Interfaces,
  Front Ports, Rear Ports. Each tab is its own ObjectChildrenView
  filtered by component_type (one ConceptComponent model backs all of
  them, so this only needed the view/URL layer, not a schema change),
  hidden when empty, exactly like core NetBox. Replace the ad hoc "Add
  component" button with the same "Add Components" dropdown real
  device pages use, one entry per type, each landing back on its own
  tab.
- When copying a real rack into a concept (or merging two real racks
  into one), automatically sync every copied device's components and
  recreate, as ConceptCables, every real cable whose both ends land on
  one of those devices - reading the same CableTermination data dcim
  itself uses, so the copy comes out cabled internally the same as the
  source. Cables reaching outside the copied rack(s), or multi-
  termination trunk cables, are skipped and reported as a count in the
  success message - the other end isn't part of the concept, so it
  can't be represented. copy_rack_to_concept() and
  merge_racks_to_concept() now return an extra cable_summary value;
  updated all their callers (views and API).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-16 10:34:26 +02:00
co-authored by Claude Sonnet 5
parent 63538c2efe
commit b289bc5aeb
8 changed files with 317 additions and 50 deletions
+21 -5
View File
@@ -35,11 +35,15 @@ Dazu:
* **Klick auf eine leere HE** öffnet direkt „Add planned device", vorausgefüllt mit
Position und Seite — genau wie bei einer echten Rack-Elevation. Den separaten
„Add planned device"-Knopf gibt es dafür nicht mehr.
* **Verkabelung von Konzept-Geräten** – Interfaces, Front-/Rear-Ports, Power-Ports/
-Outlets und Console-Ports lassen sich mit „Sync components" aus dem Gerätetyp
übernehmen (inkl. Front-↔Rear-Zuordnung von Patchpanels, 1:1 wie beim echten
Gerätetyp) und über „Connect" mit einem Concept Cable verbinden. Platzhalter ohne
Gerätetyp bekommen ihre Komponenten per Hand über „Add component".
* **Verkabelung von Konzept-Geräten, 1:1 wie bei echten Geräten** – auf der
Geräte-Detailseite gibt es dieselben Tabs wie bei einem echten `dcim.Device`:
Interfaces, Front Ports, Rear Ports, Console Ports, Console Server Ports, Power
Ports, Power Outlets (gleiche Namen, gleiche Reihenfolge, Tab nur sichtbar wenn
belegt). „Sync components" übernimmt sie 1:1 aus den Component-Templates des
Gerätetyps, inkl. Front-↔Rear-Zuordnung von Patchpanels. Über „Connect" an jeder
unverkabelten Komponente wird sie mit einem Concept Cable verbunden. Ein „Add
Components"-Dropdown (genau wie am echten Gerät) legt neue Komponenten pro Typ an —
nötig für Platzhalter ohne Gerätetyp, die nichts zum Syncen haben.
* Vollständige REST-API, Filter, CSV-Import/-Export, Bulk-Edit, Changelog, Journal,
Tags, Custom Fields und globale Suche — wie bei jedem Core-Objekt.
@@ -67,6 +71,18 @@ daran, ob der Gerätetyp Front-/Rear-Ports mit Zuordnung definiert — Kabel an
Vorderseite eines synchronisierten Patchpanel-Gerätetyps zeigen auf der Detailseite der
Komponente sofort den passenden Rear-Port samt Position an.
**Beim Kopieren eines echten Racks in ein Konzept** (und beim Zusammenführen zweier
echter Racks, siehe unten) werden die Komponenten aller übernommenen Geräte automatisch
synchronisiert, und jedes echte Kabel, dessen **beide** Enden innerhalb der kopierten
Rack(s) liegen, wird als `ConceptCable` nachgebaut — Status, Typ, Farbe und Label
inklusive. Kabel, die den Rack verlassen (zum Beispiel zum Uplink-Switch in einem
anderen Rack), lassen sich naturgemäß nicht übernehmen, weil das Gegenstück nicht Teil
des Konzepts ist; ebenso ausgelassen werden Mehrfach-Trunk-Kabel (z.B. MPO), da
`ConceptCable` nur Punkt-zu-Punkt-Verbindungen kennt. Beides wird nach dem Kopieren als
Warnung mit Anzahl gemeldet. Das Nachbilden der Verkabelung gilt nur für den Import
**echter** Racks — beim Klonen oder Zusammenführen von Konzepten (die ja schon eigene
Kabel haben können) bleibt die Verkabelung unverändert, wie bisher.
## Zusammenspiel mit den anderen Plugins
**netbox-reorder-rack (rackorder)** arbeitet auf `dcim.Device`-Querysets. Ein Konzept hat