netbox: Front/Rear port mapping breaks when multiple cables are between devices
Environment
- Python version:
- NetBox version: 2.5.10
**<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.
F 1 ---\ /---F 1
. ----\ /---- .
. -----\____________________/----- .
. -----/rear 1:1 rear 1:1\----- .
. ----/ . . \---- .
F 10---/ . . \---F 10
rear 1:10 rear 1:10
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.
F 1 ---\ /---F 1
. ----\ /---- .
. -----\_________o_________o__________o_________/----- .
. -----/rear 1:1 cable 101 cable 102 rear 1:1\----- .
. ----/ . . \---- .
F 10 ---/ . . \---F 10
rear 1:10 rear 1:10
Steps to Reproduce
- Create two devices of the same device type with multiple front ports mapping to a single back port.
- Join the two device’s rear ports together via panels that simply map one front port to one back port.
- Start putting cables between the front ports on both devices. The first one should trace through, any subsequent ones will generate and error, appear to have been added anyway, but will not trace through properly.
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.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 26 (17 by maintainers)
Commits related to this issue
- Merge pull request #4387 from netbox-community/3193-cable-tracing Fixes #3193: Fix cable tracing across multiple rear ports — committed to netbox-community/netbox by jeremystretch 4 years ago
- Changelog for #3193 — committed to netbox-community/netbox by jeremystretch 4 years ago
FYI: I can fix this as part of #3633.
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.
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.