|
@@ -2053,6 +2053,17 @@ class InterfaceForm(InterfaceCommonForm, ModularDeviceComponentForm):
|
|
|
choices=add_blank_choice(InterfacePoETypeChoices),
|
|
choices=add_blank_choice(InterfacePoETypeChoices),
|
|
|
required=False,
|
|
required=False,
|
|
|
)
|
|
)
|
|
|
|
|
+ lag_mode = TypedChoiceField(
|
|
|
|
|
+ label=_('LAG mode'),
|
|
|
|
|
+ choices=add_blank_choice(InterfaceLAGModeChoices),
|
|
|
|
|
+ required=False,
|
|
|
|
|
+ widget=HTMXSelect(hx_target_id='lag-attributes'),
|
|
|
|
|
+ )
|
|
|
|
|
+ lag_hash_policy = TypedChoiceField(
|
|
|
|
|
+ label=_('LAG hash policy'),
|
|
|
|
|
+ choices=add_blank_choice(InterfaceLAGHashPolicyChoices),
|
|
|
|
|
+ required=False,
|
|
|
|
|
+ )
|
|
|
mode = TypedChoiceField(
|
|
mode = TypedChoiceField(
|
|
|
label=_('802.1Q Mode'),
|
|
label=_('802.1Q Mode'),
|
|
|
choices=add_blank_choice(InterfaceModeChoices),
|
|
choices=add_blank_choice(InterfaceModeChoices),
|
|
@@ -2178,6 +2189,7 @@ class InterfaceForm(InterfaceCommonForm, ModularDeviceComponentForm):
|
|
|
FieldSet('vdcs', 'mtu', 'tx_power', 'enabled', 'mgmt_only', 'mark_connected', name=_('Operation')),
|
|
FieldSet('vdcs', 'mtu', 'tx_power', 'enabled', 'mgmt_only', 'mark_connected', name=_('Operation')),
|
|
|
FieldSet('parent', 'channel_id', 'bridge', 'lag', name=_('Related Interfaces')),
|
|
FieldSet('parent', 'channel_id', 'bridge', 'lag', name=_('Related Interfaces')),
|
|
|
FieldSet('poe_mode', 'poe_type', name=_('PoE')),
|
|
FieldSet('poe_mode', 'poe_type', name=_('PoE')),
|
|
|
|
|
+ FieldSet('lag_mode', 'lag_hash_policy', name=_('LAG'), html_id='lag-attributes'),
|
|
|
FieldSet(
|
|
FieldSet(
|
|
|
'mode', 'vlan_group', 'untagged_vlan', 'tagged_vlans', 'qinq_svlan', 'vlan_translation_policy',
|
|
'mode', 'vlan_group', 'untagged_vlan', 'tagged_vlans', 'qinq_svlan', 'vlan_translation_policy',
|
|
|
name=_('802.1Q Switching'),
|
|
name=_('802.1Q Switching'),
|
|
@@ -2192,11 +2204,11 @@ class InterfaceForm(InterfaceCommonForm, ModularDeviceComponentForm):
|
|
|
class Meta:
|
|
class Meta:
|
|
|
model = Interface
|
|
model = Interface
|
|
|
fields = [
|
|
fields = [
|
|
|
- 'device', 'module', 'vdcs', 'name', 'label', 'type', 'channels', 'channel_id', 'speed', 'duplex',
|
|
|
|
|
- 'enabled', 'parent', 'bridge', 'lag', 'wwn', 'mtu', 'mgmt_only', 'mark_connected', 'description',
|
|
|
|
|
- 'poe_mode', 'poe_type', 'mode', 'rf_role', 'rf_channel', 'rf_channel_frequency', 'rf_channel_width',
|
|
|
|
|
- 'tx_power', 'wireless_lans', 'untagged_vlan', 'tagged_vlans', 'qinq_svlan', 'vlan_translation_policy',
|
|
|
|
|
- 'vrf', 'owner', 'tags',
|
|
|
|
|
|
|
+ 'device', 'module', 'vdcs', 'name', 'label', 'type', 'channels', 'channel_id', 'speed', 'duplex', 'enabled',
|
|
|
|
|
+ 'parent', 'bridge', 'lag', 'wwn', 'mtu', 'mgmt_only', 'mark_connected', 'description', 'poe_mode',
|
|
|
|
|
+ 'poe_type', 'lag_mode', 'lag_hash_policy', 'mode', 'rf_role', 'rf_channel', 'rf_channel_frequency',
|
|
|
|
|
+ 'rf_channel_width', 'tx_power', 'wireless_lans', 'untagged_vlan', 'tagged_vlans', 'qinq_svlan',
|
|
|
|
|
+ 'vlan_translation_policy', 'vrf', 'owner', 'tags',
|
|
|
]
|
|
]
|
|
|
widgets = {
|
|
widgets = {
|
|
|
'speed': NumberWithOptions(
|
|
'speed': NumberWithOptions(
|
|
@@ -2204,6 +2216,27 @@ class InterfaceForm(InterfaceCommonForm, ModularDeviceComponentForm):
|
|
|
),
|
|
),
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ def __init__(self, *args, **kwargs):
|
|
|
|
|
+ super().__init__(*args, **kwargs)
|
|
|
|
|
+
|
|
|
|
|
+ # A hash policy applies only to LAG modes which hash
|
|
|
|
|
+ if get_field_value(self, 'lag_mode') not in LAG_HASH_MODES:
|
|
|
|
|
+ del self.fields['lag_hash_policy']
|
|
|
|
|
+
|
|
|
|
|
+ def clean(self):
|
|
|
|
|
+ super().clean()
|
|
|
|
|
+
|
|
|
|
|
+ # Clear a hash policy left over from a previous LAG mode
|
|
|
|
|
+ if 'lag_hash_policy' not in self.fields:
|
|
|
|
|
+ self.instance.lag_hash_policy = None
|
|
|
|
|
+
|
|
|
|
|
+ # Clear LAG attributes left over when changing a LAG interface to another type
|
|
|
|
|
+ if self.instance.is_lag and self.cleaned_data.get('type') != InterfaceTypeChoices.TYPE_LAG:
|
|
|
|
|
+ self.cleaned_data['lag_mode'] = None
|
|
|
|
|
+ self.instance.lag_hash_policy = None
|
|
|
|
|
+ if 'lag_hash_policy' in self.fields:
|
|
|
|
|
+ self.cleaned_data['lag_hash_policy'] = None
|
|
|
|
|
+
|
|
|
|
|
|
|
|
class FrontPortForm(FrontPortFormMixin, ModularDeviceComponentForm):
|
|
class FrontPortForm(FrontPortFormMixin, ModularDeviceComponentForm):
|
|
|
type = ChoiceField(
|
|
type = ChoiceField(
|