netbox: Connecting rear ports through circuit causes error when connecting devices

Environment

  • Python version: Python 3.6.8
  • NetBox version: 2.6.0

Steps to Reproduce

  1. Create a circuit
  2. Create two devices with multiple front ports mapped to a single rear port (mux
  3. Connect the two rear ports to the circuit
  4. Connect an interface to a front port of one mux
  5. Connect an interface to the corresponding front port of the other mux

At this point all is still well: both devices are connected to each other.

  1. Repeat step 4

This will fail as the first interface connection will have used the circuit termination point id in its _connected_circuittermination_id. The second interface will try to put the same termination point id in its _connected_circuittermination_id, which will fail because that is a OneToOneField.

Expected Behavior

When connecting multiple devices/interfaces through a mux they are expected to share the same circuit. Use cases are CWDM and DWDM. In Django terms: I expected _connected_circuittermination_id to be a ForeignKey, not a OneToOneField.

Observed Behavior

<class 'django.db.utils.IntegrityError'>

duplicate key value violates unique constraint "dcim_interface__connected_circuittermination_id_key"
DETAIL: Key (_connected_circuittermination_id)=(42) already exists.

Notes

This case seems similar to https://github.com/digitalocean/netbox/issues/3193, but is different. That issue applies to cables where the rear port of one mux isn’t directly connected to the rear port of another mux, but is passed through other patch panels (implemented as 1 front port mapped to 1 rear port).

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 2
  • Comments: 17 (14 by maintainers)

Most upvoted comments

I created a demo test case where Site A and Site B are connected using a DWDM circuit with a mux at both ends. Eth1 of router at Site A is connected over CH35 to the router at Site B.

I also connected a second mux at Site A to the Upg port of the first mux. Eth2 of the router at Site A is connected to CH50 of the second mux. At site B the Upg port of the mux is conneced to another circuit going to Site C. At that site there is a mux of the same type as the second mux at Site A, and the router at Site C is connected to CH50 of that one.

Just to create a scenario with nested muxes and multiple circuits 😃

The interfaces of Router A now look like this:

Schermafbeelding 2019-10-23 om 13 43 57

@steffann i see a scenario that would not be covered. when you connect a multiplexer to a extension port of another multiplexer (often 1300nm cwdm or 1550nm dwdm) to extend your network this could break things in documentation…

+----------+           +---MUX1---+          +---MUX2---+
| Device A |--[cable]--| Front 1  |          |          |
+----------+           |          |          |          |
                       |     Rear |--[cbl]---| Front 1  |
+----------+           |          |          |          |  +-----------+
| Device B |--[cable]--| Front 2  |          |     Rear |--| Circuit 1 |--\
+----------+           +----------+          +----------+  +-----------+   |
                                                                           |
  /-----------------------------------------------------------------------/
 |
 |            +---MUX3---+           +---MUX4---+
 |            |  Front 1 |---[cbl]---| Rear     |
 |            |          |           |          |           +-----------+
  \-----------| Rear     |           |  Front 1 |--[cable]--| Device A2 |  
              |          |           |          |           +-----------+
              |  Front 2 |           |  Front 2 |--[cable]--| Device B2 |
              +----------+           +----------+           +-----------+

–> “From Site1 to Site2 via Mux-1 1330nm - Mux-2 1300nm - DarkFiberX - Mux-3 1300nm - Mux-4 1330nm”

That get even more complicated when i add PatchPanel to NetBox…

Thank you very mutch for working on this!

@bsteinert I’ve the exact same issue as you’ve, to make things worse some multiplexers only have front-ports which isn’t supported at all since a Front port requires a rear-port.

Well, the term “rear-port” is used for the port that aggregates one or more front ports. It doesn’t have to be physically on the rear of the device 😃 And a “front-port” may physically be on the back.