mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-15 19:52:52 -06:00
Closes #4814: Allow nested LAG interfaces
This commit is contained in:
parent
ed65603632
commit
f37997ac54
@ -4,7 +4,7 @@ Interfaces in NetBox represent network interfaces used to exchange data with con
|
|||||||
|
|
||||||
Interfaces may be physical or virtual in nature, but only physical interfaces may be connected via cables. Cables can connect interfaces to pass-through ports, circuit terminations, or other interfaces.
|
Interfaces may be physical or virtual in nature, but only physical interfaces may be connected via cables. Cables can connect interfaces to pass-through ports, circuit terminations, or other interfaces.
|
||||||
|
|
||||||
Physical interfaces may be arranged into a link aggregation group (LAG) and associated with a parent LAG (virtual) interface. Like all virtual interfaces, LAG interfaces cannot be connected physically.
|
Physical interfaces may be arranged into a link aggregation group (LAG) and associated with a parent LAG (virtual) interface. LAG interfaces can be recursively nested to model bonding of trunk groups. Like all virtual interfaces, LAG interfaces cannot be connected physically.
|
||||||
|
|
||||||
IP addresses can be assigned to interfaces. VLANs can also be assigned to each interface as either tagged or untagged. (An interface may have only one untagged VLAN.)
|
IP addresses can be assigned to interfaces. VLANs can also be assigned to each interface as either tagged or untagged. (An interface may have only one untagged VLAN.)
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
### Enhancements
|
### Enhancements
|
||||||
|
|
||||||
* [#4540](https://github.com/netbox-community/netbox/issues/4540) - Add IP address status type for SLAAC
|
* [#4540](https://github.com/netbox-community/netbox/issues/4540) - Add IP address status type for SLAAC
|
||||||
|
* [#4814](https://github.com/netbox-community/netbox/issues/4814) - Allow nested LAG interfaces
|
||||||
* [#4991](https://github.com/netbox-community/netbox/issues/4991) - Add Python and NetBox versions to error page
|
* [#4991](https://github.com/netbox-community/netbox/issues/4991) - Add Python and NetBox versions to error page
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -2686,7 +2686,10 @@ class InterfaceForm(InterfaceCommonForm, BootstrapMixin, forms.ModelForm):
|
|||||||
device_query = Q(device=device)
|
device_query = Q(device=device)
|
||||||
if device.virtual_chassis:
|
if device.virtual_chassis:
|
||||||
device_query |= Q(device__virtual_chassis=device.virtual_chassis)
|
device_query |= Q(device__virtual_chassis=device.virtual_chassis)
|
||||||
self.fields['lag'].queryset = Interface.objects.filter(device_query, type=InterfaceTypeChoices.TYPE_LAG)
|
self.fields['lag'].queryset = Interface.objects.filter(
|
||||||
|
device_query,
|
||||||
|
type=InterfaceTypeChoices.TYPE_LAG
|
||||||
|
).exclude(pk=self.instance.pk)
|
||||||
|
|
||||||
# Add current site to VLANs query params
|
# Add current site to VLANs query params
|
||||||
self.fields['untagged_vlan'].widget.add_query_param('site_id', device.site.pk)
|
self.fields['untagged_vlan'].widget.add_query_param('site_id', device.site.pk)
|
||||||
|
@ -702,18 +702,12 @@ class Interface(CableTermination, ComponentModel, BaseInterface):
|
|||||||
})
|
})
|
||||||
|
|
||||||
# A virtual interface cannot have a parent LAG
|
# A virtual interface cannot have a parent LAG
|
||||||
if self.type in NONCONNECTABLE_IFACE_TYPES and self.lag is not None:
|
if self.type == InterfaceTypeChoices.TYPE_VIRTUAL and self.lag is not None:
|
||||||
raise ValidationError({
|
raise ValidationError({'lag': "Virtual interfaces cannot have a parent LAG interface."})
|
||||||
'lag': "{} interfaces cannot have a parent LAG interface.".format(self.get_type_display())
|
|
||||||
})
|
|
||||||
|
|
||||||
# Only a LAG can have LAG members
|
# A LAG interface cannot be its own parent
|
||||||
if self.type != InterfaceTypeChoices.TYPE_LAG and self.member_interfaces.exists():
|
if self.pk and self.lag_id == self.pk:
|
||||||
raise ValidationError({
|
raise ValidationError({'lag': "A LAG interface cannot be its own parent."})
|
||||||
'type': "Cannot change interface type; it has LAG members ({}).".format(
|
|
||||||
", ".join([iface.name for iface in self.member_interfaces.all()])
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
# Validate untagged VLAN
|
# Validate untagged VLAN
|
||||||
if self.untagged_vlan and self.untagged_vlan.site not in [self.parent.site, None]:
|
if self.untagged_vlan and self.untagged_vlan.site not in [self.parent.site, None]:
|
||||||
|
Loading…
Reference in New Issue
Block a user