mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Permit the assignment of virtual interfaces as parents
This commit is contained in:
@ -3148,7 +3148,6 @@ class InterfaceCreateForm(ComponentCreateForm, InterfaceCommonForm):
|
|||||||
required=False,
|
required=False,
|
||||||
query_params={
|
query_params={
|
||||||
'device_id': '$device',
|
'device_id': '$device',
|
||||||
'kind': 'physical',
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
lag = DynamicModelChoiceField(
|
lag = DynamicModelChoiceField(
|
||||||
@ -3235,10 +3234,7 @@ class InterfaceBulkEditForm(
|
|||||||
)
|
)
|
||||||
parent = DynamicModelChoiceField(
|
parent = DynamicModelChoiceField(
|
||||||
queryset=Interface.objects.all(),
|
queryset=Interface.objects.all(),
|
||||||
required=False,
|
required=False
|
||||||
query_params={
|
|
||||||
'kind': 'physical',
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
lag = DynamicModelChoiceField(
|
lag = DynamicModelChoiceField(
|
||||||
queryset=Interface.objects.all(),
|
queryset=Interface.objects.all(),
|
||||||
|
@ -623,14 +623,14 @@ class Interface(ComponentModel, BaseInterface, CableTermination, PathEndpoint):
|
|||||||
f"is not part of virtual chassis {self.device.virtual_chassis}."
|
f"is not part of virtual chassis {self.device.virtual_chassis}."
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# An interface cannot be its own parent
|
||||||
|
if self.pk and self.parent_id == self.pk:
|
||||||
|
raise ValidationError({'parent': "An interface cannot be its own parent."})
|
||||||
|
|
||||||
# A physical interface cannot have a parent interface
|
# A physical interface cannot have a parent interface
|
||||||
if self.type != InterfaceTypeChoices.TYPE_VIRTUAL and self.parent is not None:
|
if self.type != InterfaceTypeChoices.TYPE_VIRTUAL and self.parent is not None:
|
||||||
raise ValidationError({'parent': "Only virtual interfaces may be assigned to a parent interface."})
|
raise ValidationError({'parent': "Only virtual interfaces may be assigned to a parent interface."})
|
||||||
|
|
||||||
# A virtual interface cannot be a parent interface
|
|
||||||
if self.parent is not None and self.parent.type == InterfaceTypeChoices.TYPE_VIRTUAL:
|
|
||||||
raise ValidationError({'parent': "Virtual interfaces may not be parents of other interfaces."})
|
|
||||||
|
|
||||||
# An interface's LAG must belong to the same device or virtual chassis
|
# An interface's LAG must belong to the same device or virtual chassis
|
||||||
if self.lag and self.lag.device != self.device:
|
if self.lag and self.lag.device != self.device:
|
||||||
if self.device.virtual_chassis is None:
|
if self.device.virtual_chassis is None:
|
||||||
|
@ -281,13 +281,11 @@
|
|||||||
{% include 'panel_table.html' with table=vlan_table heading="VLANs" %}
|
{% include 'panel_table.html' with table=vlan_table heading="VLANs" %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% if not object.is_virtual %}
|
<div class="row">
|
||||||
<div class="row">
|
<div class="col-md-12">
|
||||||
<div class="col-md-12">
|
{% include 'panel_table.html' with table=child_interfaces_table heading="Child Interfaces" %}
|
||||||
{% include 'panel_table.html' with table=child_interfaces_table heading="Child Interfaces" %}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
{% plugin_full_width_page object %}
|
{% plugin_full_width_page object %}
|
||||||
|
Reference in New Issue
Block a user