Moving a module between devices doesn't move it's associated components #7048

Closed
opened 2025-12-29 19:48:20 +01:00 by adam · 3 comments
Owner

Originally created by @cpmills1975 on GitHub (Sep 29, 2022).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.3.4

Python version

3.10

Steps to Reproduce

  1. Create a device and add some module bays and no interfaces
  2. Create a second device and add some module bays and no interfaces
  3. Create a module type and add some interfaces to the module template
  4. Add a new module to a device making sure "Replicate components" is selected
  5. Observe that the device has the module inserted and that the interfaces on the device belong to the module
  6. Edit the module and move it to a bay in the second device
  7. Observe the interfaces table for both devices, the interfaces instantiated at 4 remain on the first device associated with the module that is now in the second device and that there is still no interfaces on the second device
  8. Observe that the modules table for the second device shows the module. Clicking on that module and viewing it's associated interfaces indicate that those interfaces remain associated with the first device.

Expected Behavior

Ideally changing the device to which a module is associated should move the interfaces to the new device. At a minimum, removing the association between between a device and an instance of a module should disassociate the interfaces generated from the module, perhaps leaving them as 'standalone' interfaces lest there be documented cables that need to be cleared up. Perhaps it should be impossible to remove a module while there are connected components associated with that module?

Observed Behavior

Interfaces (and perhaps other component types) remain associated with a module in a device even when that module is moved to a new device.

Originally created by @cpmills1975 on GitHub (Sep 29, 2022). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.3.4 ### Python version 3.10 ### Steps to Reproduce 1. Create a device and add some module bays and no interfaces 2. Create a second device and add some module bays and no interfaces 3. Create a module type and add some interfaces to the module template 4. Add a new module to a device making sure "Replicate components" is selected 5. Observe that the device has the module inserted and that the interfaces on the device belong to the module 6. Edit the module and move it to a bay in the second device 7. Observe the interfaces table for both devices, the interfaces instantiated at 4 remain on the first device associated with the module that is now in the second device and that there is still no interfaces on the second device 8. Observe that the modules table for the second device shows the module. Clicking on that module and viewing it's associated interfaces indicate that those interfaces remain associated with the first device. ### Expected Behavior Ideally changing the device to which a module is associated should move the interfaces to the new device. At a minimum, removing the association between between a device and an instance of a module should disassociate the interfaces generated from the module, perhaps leaving them as 'standalone' interfaces lest there be documented cables that need to be cleared up. Perhaps it should be impossible to remove a module while there are connected components associated with that module? ### Observed Behavior Interfaces (and perhaps other component types) remain associated with a module in a device even when that module is moved to a new device.
adam added the type: bugstatus: accepted labels 2025-12-29 19:48:20 +01:00
adam closed this issue 2025-12-29 19:48:20 +01:00
Author
Owner

@kkthxbye-code commented on GitHub (Sep 30, 2022):

I actually think it makes the most sense to disallow moving modules. Moving interfaces has a whole slew of problems and edge cases and I'm not sure it is something we want to support. Even just moving the card to a different slot is messy if the expectation is that interfaces are moved too. We would have to generate the interface names again with the old position, see if they exist on the device+module, regenerate their names with the new index and move them to a new device. This is not taking into account bridging and child interfaces, which provide more issues. Also, what happens to interfaces that don't match the interface template? Are they just moved as is?

I just don't see a clean way to implement moving modules in a way that makes sense. The easiest fix to the immediate issue would be to make sure the module reference in the existing interfaces is deleted when moving modules. Then only the module itself is moved.

Maybe @jeremystretch can comment on the original intention.

@kkthxbye-code commented on GitHub (Sep 30, 2022): I actually think it makes the most sense to disallow moving modules. Moving interfaces has a whole slew of problems and edge cases and I'm not sure it is something we want to support. Even just moving the card to a different slot is messy if the expectation is that interfaces are moved too. We would have to generate the interface names again with the old position, see if they exist on the device+module, regenerate their names with the new index and move them to a new device. This is not taking into account bridging and child interfaces, which provide more issues. Also, what happens to interfaces that don't match the interface template? Are they just moved as is? I just don't see a clean way to implement moving modules in a way that makes sense. The easiest fix to the immediate issue would be to make sure the module reference in the existing interfaces is deleted when moving modules. Then only the module itself is moved. Maybe @jeremystretch can comment on the original intention.
Author
Owner

@cpmills1975 commented on GitHub (Oct 1, 2022):

I think the minimum I'd like to see is disassociating the interfaces from the module being moved. If they could be re-created in the new location, brilliant.

As a way forward, how about having a subtly different edit form to the create form which said something like "Replicate new interfaces" if the device name is changed? This would generate a new set of interfaces using the same as the original replicate code, but leave the existing ones where they are without the link to the module?

@cpmills1975 commented on GitHub (Oct 1, 2022): I think the minimum I'd like to see is disassociating the interfaces from the module being moved. If they could be re-created in the new location, brilliant. As a way forward, how about having a subtly different edit form to the create form which said something like "Replicate new interfaces" if the device name is changed? This would generate a new set of interfaces using the same as the original replicate code, but leave the existing ones where they are without the link to the module?
Author
Owner

@jeremystretch commented on GitHub (Oct 3, 2022):

I just don't see a clean way to implement moving modules in a way that makes sense.

Agreed. I believe the initial intent was to not allow moving a module from one device to another (just as we restrict device components); this was likely an oversight.

I'm going to resolve this bug by fixing the form to disallow modifying the device to which an existing module is assigned. I'm open to a feature request to officially support this ability, however as @kkthxbye-code mentions it would need to be very thoroughly thought out as we don't current support the reassignment of device components.

@jeremystretch commented on GitHub (Oct 3, 2022): > I just don't see a clean way to implement moving modules in a way that makes sense. Agreed. I believe the initial intent was to not allow moving a module from one device to another (just as we restrict device components); this was likely an oversight. I'm going to resolve this bug by fixing the form to disallow modifying the device to which an existing module is assigned. I'm open to a feature request to officially support this ability, however as @kkthxbye-code mentions it would need to be very thoroughly thought out as we don't current support the reassignment of device components.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#7048