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:
@@ -41,7 +41,7 @@ class RackConceptViewSet(NetBoxModelViewSet):
|
||||
tenant = data.get('tenant')
|
||||
|
||||
try:
|
||||
concept, warnings = deploy_utils.copy_rack_to_concept(
|
||||
concept, warnings, cable_summary = deploy_utils.copy_rack_to_concept(
|
||||
rack=rack,
|
||||
name=data['name'],
|
||||
status=data['status'],
|
||||
@@ -60,6 +60,7 @@ class RackConceptViewSet(NetBoxModelViewSet):
|
||||
|
||||
result = RackConceptSerializer(concept, context={'request': request}).data
|
||||
result['warnings'] = warnings
|
||||
result['cables'] = cable_summary
|
||||
return Response(result, status=status.HTTP_201_CREATED)
|
||||
|
||||
@action(detail=True, methods=['post'])
|
||||
|
||||
Reference in New Issue
Block a user