Closes #12135: Prevent the deletion of interfaces with children

This commit is contained in:
Jeremy Stretch 2023-10-20 08:13:00 -04:00
parent 7efbfabc0b
commit aeea7e0d43
5 changed files with 45 additions and 1 deletions

View File

@ -77,6 +77,9 @@ If selected, this component will be treated as if a cable has been connected.
Virtual interfaces can be bound to a physical parent interface. This is helpful for modeling virtual interfaces which employ encapsulation on a physical interface, such as an 802.1Q VLAN-tagged subinterface. Virtual interfaces can be bound to a physical parent interface. This is helpful for modeling virtual interfaces which employ encapsulation on a physical interface, such as an 802.1Q VLAN-tagged subinterface.
!!! note
An interface with one or more child interfaces assigned cannot be deleted until all its child interfaces have been deleted or reassigned.
### Bridged Interface ### Bridged Interface
Interfaces can be bridged to other interfaces on a device in two manners: symmetric or grouped. Interfaces can be bridged to other interfaces on a device in two manners: symmetric or grouped.

View File

@ -16,6 +16,9 @@ The interface's name. Must be unique to the assigned VM.
Identifies the parent interface of a subinterface (e.g. used to employ encapsulation). Identifies the parent interface of a subinterface (e.g. used to employ encapsulation).
!!! note
An interface with one or more child interfaces assigned cannot be deleted until all its child interfaces have been deleted or reassigned.
### Bridged Interface ### Bridged Interface
An interface on the same VM with which this interface is bridged. An interface on the same VM with which this interface is bridged.

View File

@ -0,0 +1,19 @@
# Generated by Django 4.2.6 on 2023-10-20 11:48
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('dcim', '0181_rename_device_role_device_role'),
]
operations = [
migrations.AlterField(
model_name='interface',
name='parent',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='child_interfaces', to='dcim.interface'),
),
]

View File

@ -537,7 +537,7 @@ class BaseInterface(models.Model):
) )
parent = models.ForeignKey( parent = models.ForeignKey(
to='self', to='self',
on_delete=models.SET_NULL, on_delete=models.PROTECT,
related_name='child_interfaces', related_name='child_interfaces',
null=True, null=True,
blank=True, blank=True,

View File

@ -0,0 +1,19 @@
# Generated by Django 4.2.6 on 2023-10-20 11:48
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('virtualization', '0036_virtualmachine_config_template'),
]
operations = [
migrations.AlterField(
model_name='vminterface',
name='parent',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='child_interfaces', to='virtualization.vminterface'),
),
]