Adopt child interfaces when adopting components

This commit is contained in:
kkthxbye-code 2022-05-14 12:17:22 +02:00
parent f415d81049
commit 1c0bd6f788

View File

@ -1107,6 +1107,14 @@ class Module(NetBoxModel, ConfigContextModel):
# Assign it to the module # Assign it to the module
existing_item.module = self existing_item.module = self
update_instances.append(existing_item) update_instances.append(existing_item)
# Adopt child interfaces
if component_model is Interface:
for child_interface in existing_item.child_interfaces.filter(module__isnull=True):
child_interface.module = self
update_instances.append(child_interface)
# If we adopted, skip creation
continue continue
# Only create new components if replication is enabled # Only create new components if replication is enabled