mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-13 22:03:32 +01:00
Front/Rear port mapping breaks when multiple cables are between devices #2621
Closed
opened 2025-12-29 18:20:28 +01:00 by adam
·
26 comments
No Branch/Tag Specified
main
21050-device-oob-ip-may-become-orphaned
21102-fix-graphiql-explorer
20911-dropdown
20239-plugin-menu-classes-mutable-state
21097-graphql-id-lookups
feature
fix_module_substitution
20923-dcim-templates
20044-elevation-stuck-lightmode
feature-ip-prefix-link
v4.5-beta1-release
20068-import-moduletype-attrs
20766-fix-german-translation-code-literals
20378-del-script
7604-filter-modifiers-v3
circuit-swap
12318-case-insensitive-uniqueness
20637-improve-device-q-filter
20660-script-load
19724-graphql
20614-update-ruff
14884-script
02496-max-page
19720-macaddress-interface-generic-relation
19408-circuit-terminations-export-templates
20203-openapi-check
fix-19669-api-image-download
7604-filter-modifiers
19275-fixes-interface-bulk-edit
fix-17794-get_field_value_return_list
11507-show-aggregate-and-rir-on-api
9583-add_column_specific_search_field_to_tables
v4.5.0
v4.4.10
v4.4.9
v4.5.0-beta1
v4.4.8
v4.4.7
v4.4.6
v4.4.5
v4.4.4
v4.4.3
v4.4.2
v4.4.1
v4.4.0
v4.3.7
v4.4.0-beta1
v4.3.6
v4.3.5
v4.3.4
v4.3.3
v4.3.2
v4.3.1
v4.3.0
v4.2.9
v4.3.0-beta2
v4.2.8
v4.3.0-beta1
v4.2.7
v4.2.6
v4.2.5
v4.2.4
v4.2.3
v4.2.2
v4.2.1
v4.2.0
v4.1.11
v4.1.10
v4.1.9
v4.1.8
v4.2-beta1
v4.1.7
v4.1.6
v4.1.5
v4.1.4
v4.1.3
v4.1.2
v4.1.1
v4.1.0
v4.0.11
v4.0.10
v4.0.9
v4.1-beta1
v4.0.8
v4.0.7
v4.0.6
v4.0.5
v4.0.3
v4.0.2
v4.0.1
v4.0.0
v3.7.8
v3.7.7
v4.0-beta2
v3.7.6
v3.7.5
v4.0-beta1
v3.7.4
v3.7.3
v3.7.2
v3.7.1
v3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
v1.0.4
v1.0.3-r1
v1.0.3
1.0.0
Labels
Clear labels
beta
breaking change
complexity: high
complexity: low
complexity: medium
needs milestone
netbox
pending closure
plugin candidate
pull-request
severity: high
severity: low
severity: medium
status: accepted
status: backlog
status: blocked
status: duplicate
status: needs owner
status: needs triage
status: revisions needed
status: under review
topic: GraphQL
topic: Internationalization
topic: OpenAPI
topic: UI/UX
topic: cabling
topic: event rules
topic: htmx navigation
topic: industrialization
topic: migrations
topic: plugins
topic: scripts
topic: templating
topic: testing
type: bug
type: deprecation
type: documentation
type: feature
type: housekeeping
type: translation
Mirrored from GitHub Pull Request
Milestone
No items
No Milestone
Projects
Clear projects
No project
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: starred/netbox#2621
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @toddam310 on GitHub (May 17, 2019).
Environment
**<class 'django.db.utils.IntegrityError'>
duplicate key value violates unique constraint "dcim_interface__connected_circuittermination_id_key"
DETAIL: Key (_connected_circuittermination_id)=(22) already exists.**
When I have two devices that I am mapping multiple front ports to a rear port on each and I join the rear ports of the two devices together, I can put a device on front port 1 on device A and it will connect all the way through to a device placed on front port 1 on device B. Same for any device I connect to a front port on Device A, it will show as connected to the corresponding port on device B.
Now, when I put any other cables via panels that are mapped as one front port to one back port (like a standard patch panel would be) between the rear ports of device A & B, I can again put a device on front port 1 on device A and it will connect all the way through to a device placed on front port 1 on device B. However, when I add a second device via a cable to the next front port on device A, I get the above error. Also, the device port will show up as cabled, even after the error, but the trace will not go to the intended device on the other end and will instead go to the first device built.
Steps to Reproduce
Expected Behavior
I was expecting a something connected on device A port 2, to be able to connect to Device B port 2 regardless of whether there are additional cables in between.
Observed Behavior
Instead I get an error when adding a second connection (first connection will work) and the resulting cable's trace will not map correctly.
@DanSheps commented on GitHub (May 21, 2019):
Does the middle device/panel have 10 front/10 rear ports as well?
The integrity error points to you trying to create a cable where a circuit exists.
@toddam310 commented on GitHub (May 21, 2019):
No, the panels can be anywhere from 24 to 48 ports (front and back) and are one-to-one mapped front to rear. There are no circuits in between.
@DanSheps commented on GitHub (May 23, 2019):
I am unable to reproduce this. Please confirm it is modeled correctly here:
https://master.netbox.dansheps.com/dcim/devices/5/
@fablabo commented on GitHub (May 27, 2019):
The middle device connecting cable 101 and cable 102 probably only has one front and one rear port. This results in a single path. I've created PP1, PP2 and PP3 on your demo install to reproduce the error.
Creating cable number 30 did throw an exception and a trace also fails.
To allow multiple connections between two panels which have a one to many port relation, a multi position front port could be a solution.
A real life situation for this setup would be a cable plant which uses MPO patches.
@DanSheps commented on GitHub (May 28, 2019):
I don't think you would generally go rear port to front port. It owuld normally be front:rear-rear:front-front:rear-rear:front
@fablabo commented on GitHub (May 28, 2019):
MPO patching is becoming quite common where you heave a breakout (front:rear 12:1 or 24:1) on the far and near end, and N+1 MPO patchpanels in between. For this you'll need 12:12 or 24:24 front:rear ports.
@jeremystretch commented on GitHub (May 29, 2019):
@fablabo Please expand on the steps to reproduce, noting the exact objects to create/update in each step. This will allow us to try recreating the reported issue.
@fablabo commented on GitHub (May 31, 2019):
Add Site
Add Manufacturers
Add Device Role
Create MPO to 12x LC breakout box
Add Device type
Add Rear Port
Add Front Port
Create MPO Patchpanel
Add Device type
Add Rear Port
Add Front Port
Create generic switch
Add Device Type
Add Interfaces
Create patchpanels
Add Device
Add Device
Add Device
Add Device
Add Device
Connect:
At this stage Switch 1 Interface 1 connects to Switch 2 Interface 1. A trace shows 5 cables, both ending on a SFP+ port.
Now we add a second cable from Switch 2 Interface 2 to PP2 LC2 which results in an error:
The new cable is added but viewing or deleting it results in a similar error.
Ending up in a loop where you can't add or edit a cable is unfortunate but understandable. MPOrear2 only has 1 position while MPO1 on PP2 has 12.
To continue we can increase the amount of positions on both MPOrear ports on Patchfarm1.
Next we add a connection between Switch1, Interface 2 to PP1, front port LC2 just like we did between Switch2 and PP2 front port LC2.
This results in the following error:
Again the cable is added but the trace between Switch1 interface 2 and Switch 2 interface 2 only shows tw0 cables up-to the MPOrear port.
Next we can delete all cables (without errors) and the same cables can be recreated without errors when they are added in a different order.
Connect:
This results in the same but without errors. Interface 2 on both switches do show a cable but the Connection column shows Not connected.
As I've already mentioned before the result is very understandable. In both procedures the first connection made connects fully from near to far. In the first procedure a connection ends on the 'leaving' MPO1 port which has multiple position but the connecting MPOrear[1-2] only has one position. In the second procedure a connection ends on the MPOrear[1-2] port which has multiple position but only one of them is connected to the front port.
Without any knowledge on the internals of netbox I'm guessing that a solution could either be a fully transparent mapping between front and rear ports for a certain type (no positions), or a front port with multiple positions.
The error handling could be improved by not allowing a second connection on a path which doesn't have sufficient "positions", but the result doesn't seem to be a bug/issue, just the way ports and cables are currently setup.
Providing a way to model a transparent front/rear paths or a front port with multiple positions would be a great feature to allow for WDM devices and MPO patchfarms. But that would make this a feature request, not an issue.
@steffann commented on GitHub (Jun 12, 2019):
I got the same problem when modelling two CWDM/DWDM muxes connected over a circuit:
When connecting the first device interface to the left mux (say to F1) everything is fine. It stores the circuit termination ID of the A side of the circuit in
_connected_circuittermination_id. However when connecting the second device interface to the same mux (say to F2) theduplicate key value violates unique constraint "dcim_interface__connected_circuittermination_id_key" DETAIL: Key (_connected_circuittermination_id)=(22) already existserror appears as it finds the same circuit termination ID and tries to store it in_connected_circuittermination_id. Because it is aOneToOneFieldthat is not allowed.I don't see any issue with changing
_connected_circuittermination_idtoForeignKeythough, which solves the problem. I tested this in my own setup and it works fine. I'll submit a pull request for this change.@fablabo commented on GitHub (Jun 12, 2019):
@steffann Have you tried the trace feature after your change and adding multiple interfaces to the muxes ?
For the trace feature to work it would have to "remember" the trace left e.g. port F3 on the left, trace the circuit, enter the next rear port and then exit F3 on the right.
@steffann commented on GitHub (Jun 12, 2019):
It actually works great! I didn't expect it, but I tested a quite complex setup:
So two connections from device 1 to device 2 over two circuits, each with a DWDM Mux on both sides. The traces work fine! Screenshots attached.
@fablabo commented on GitHub (Jun 16, 2019):
@steffann Your fix doesn't seem to do the trick for me. When I try to re-create your setup i'm seeing the same connection in the Interfaces table of the Device view. So on Device 1 both Te3/4 and Te3/6 show a connection to Device 2 Te6/2 and Device 2 shows both Te6/2 and Te6/3 connected to Te3/4.
The trace does work and shows all interfaces correctly.
When creating the following setup using front/rear connections instead of a Circuit, all traces end up on the first port on the far end.
@steffann commented on GitHub (Jun 16, 2019):
Hi,
Ah right, I hadn't looked at the cached interface info. I'll check where that information is filled in and fix that.
Cheers,
Sander
@steffann commented on GitHub (Jun 16, 2019):
Hi,
And done. Can you please try again with the latest patch?
Cheers!
Sander
@fablabo commented on GitHub (Jun 17, 2019):
Thanks for the effort @steffann but unfortunately no joy so far. On the near end I've connected 9 Gi ports to 9 different cwdm channels. on the fear end only the first two channels are connected.


@steffann commented on GitHub (Jun 17, 2019):
Hi,
Did you re-create the cables? The change is when saving the cable. Doing this might help:
python3 manage.py shell
Cheers,
Sander
@fablabo commented on GitHub (Jun 17, 2019):
I did a clean install with #3254
@steffann commented on GitHub (Jun 17, 2019):
Hi Fabian,
Sorry, apparently I forgot to push my branch facepalm
Please try again
Sander
@fablabo commented on GitHub (Jun 17, 2019):
Haha no worries. It's starting to look very promising!
SwitchA

SwitchB

Trace

A minor cosmetic issue in the termination of the Circuit

I'm thinking this should be the common ports on both muxes.
#3254 is a great change to allow for a Circuit between multiposition rear-ports, but it isn't yet a fix for the issue described by @toddam310 where multiple cables and front/rear ports are used between multiposition rear-ports.
@steffann commented on GitHub (Jun 17, 2019):
Ok, my patch got rejected. Let's continue the discussion on what the proper solution is.
@steffann commented on GitHub (Jun 17, 2019):
I suggest using a subset of what I proposed as a patch:
dcim.Interface._connected_circuitterminationto a ForeignKey instead of OneToOnedcim.cable.get_path_endpointsto follow circuitsThat way there won't be a change to the endpoint data model, CWDM and DWDM circuits will work, and endpoints will show the correct peer endpoint.
If this is an acceptable solution I can have a clean patch set ready in minutes. The development and alpha testing has been done already in my previous patch proposal :)
@steffann commented on GitHub (Jun 17, 2019):
This time I'll wait with clicking the pull request button until we have agreement :)
@steffann commented on GitHub (Jun 22, 2019):
I just realised what @fablabo has been trying to tell me: these are two similar but slightly different problems, and my solution doesn't solve the original question. I will therefore move my stuff to a separate issue.
@steffann commented on GitHub (Nov 1, 2019):
FYI: I can fix this as part of #3633.
@steffann commented on GitHub (Apr 21, 2020):
The case where a rear port has only one position (basically extending the cable) raises an exception. This is caused by such 1-on-1 ports being pushed onto the
position_stack, even though there doesn't have to be a corresponding rear port to pop it again.@jeremystretch commented on GitHub (Apr 21, 2020):
@steffann please open a new issue for this.