From beb0aff6569ca2f6656c765077cba68d69386453 Mon Sep 17 00:00:00 2001 From: Brian Tiemann Date: Sun, 23 Feb 2025 21:36:19 -0500 Subject: [PATCH] Add VLAN Translation Policy to bulk edit forms and tables for Interface and VMInterface --- netbox/dcim/forms/bulk_edit.py | 8 +++++--- netbox/dcim/tables/devices.py | 2 +- netbox/virtualization/forms/bulk_edit.py | 14 +++++++++++--- netbox/virtualization/tables/virtualmachines.py | 2 +- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/netbox/dcim/forms/bulk_edit.py b/netbox/dcim/forms/bulk_edit.py index da5a45f15..e50804df8 100644 --- a/netbox/dcim/forms/bulk_edit.py +++ b/netbox/dcim/forms/bulk_edit.py @@ -1411,7 +1411,7 @@ class InterfaceBulkEditForm( form_from_model(Interface, [ 'label', 'type', 'parent', 'bridge', 'lag', 'speed', 'duplex', 'wwn', 'mtu', 'mgmt_only', 'mark_connected', 'description', 'mode', 'rf_role', 'rf_channel', 'rf_channel_frequency', 'rf_channel_width', 'tx_power', - 'wireless_lans' + 'wireless_lans', 'vlan_translation_policy' ]) ): enabled = forms.NullBooleanField( @@ -1564,7 +1564,9 @@ class InterfaceBulkEditForm( FieldSet('vdcs', 'mtu', 'tx_power', 'enabled', 'mgmt_only', 'mark_connected', name=_('Operation')), FieldSet('poe_mode', 'poe_type', name=_('PoE')), FieldSet('parent', 'bridge', 'lag', name=_('Related Interfaces')), - FieldSet('mode', 'vlan_group', 'untagged_vlan', 'qinq_svlan', name=_('802.1Q Switching')), + FieldSet( + 'mode', 'vlan_group', 'untagged_vlan', 'qinq_svlan', 'vlan_translation_policy', name=_('802.1Q Switching') + ), FieldSet( TabbedGroups( FieldSet('tagged_vlans', name=_('Assignment')), @@ -1579,7 +1581,7 @@ class InterfaceBulkEditForm( nullable_fields = ( 'module', 'label', 'parent', 'bridge', 'lag', 'speed', 'duplex', 'wwn', 'vdcs', 'mtu', 'description', 'poe_mode', 'poe_type', 'mode', 'rf_channel', 'rf_channel_frequency', 'rf_channel_width', 'tx_power', - 'untagged_vlan', 'tagged_vlans', 'qinq_svlan', 'vrf', 'wireless_lans' + 'untagged_vlan', 'tagged_vlans', 'qinq_svlan', 'vrf', 'wireless_lans', 'vlan_translation_policy', ) def __init__(self, *args, **kwargs): diff --git a/netbox/dcim/tables/devices.py b/netbox/dcim/tables/devices.py index d4f2f74b3..924ba0aaf 100644 --- a/netbox/dcim/tables/devices.py +++ b/netbox/dcim/tables/devices.py @@ -671,7 +671,7 @@ class InterfaceTable(BaseInterfaceTable, ModularDeviceComponentTable, PathEndpoi 'rf_role', 'rf_channel', 'rf_channel_frequency', 'rf_channel_width', 'tx_power', 'description', 'mark_connected', 'cable', 'cable_color', 'wireless_link', 'wireless_lans', 'link_peer', 'connection', 'tags', 'vdcs', 'vrf', 'l2vpn', 'tunnel', 'ip_addresses', 'fhrp_groups', 'untagged_vlan', 'tagged_vlans', - 'qinq_svlan', 'inventory_items', 'created', 'last_updated', + 'qinq_svlan', 'inventory_items', 'created', 'last_updated', 'vlan_translation_policy' ) default_columns = ('pk', 'name', 'device', 'label', 'enabled', 'type', 'description') diff --git a/netbox/virtualization/forms/bulk_edit.py b/netbox/virtualization/forms/bulk_edit.py index 3b5bf6c03..80b665047 100644 --- a/netbox/virtualization/forms/bulk_edit.py +++ b/netbox/virtualization/forms/bulk_edit.py @@ -6,7 +6,7 @@ from dcim.constants import INTERFACE_MTU_MAX, INTERFACE_MTU_MIN from dcim.forms.mixins import ScopedBulkEditForm from dcim.models import Device, DeviceRole, Platform, Site from extras.models import ConfigTemplate -from ipam.models import VLAN, VLANGroup, VRF +from ipam.models import VLAN, VLANGroup, VLANTranslationPolicy, VRF from netbox.forms import NetBoxModelBulkEditForm from tenancy.models import Tenant from utilities.forms import BulkRenameForm, add_blank_choice @@ -242,15 +242,23 @@ class VMInterfaceBulkEditForm(NetBoxModelBulkEditForm): required=False, label=_('VRF') ) + vlan_translation_policy = DynamicModelChoiceField( + queryset=VLANTranslationPolicy.objects.all(), + required=False, + label=_('VLAN Translation Policy') + ) model = VMInterface fieldsets = ( FieldSet('mtu', 'enabled', 'vrf', 'description'), FieldSet('parent', 'bridge', name=_('Related Interfaces')), - FieldSet('mode', 'vlan_group', 'untagged_vlan', 'tagged_vlans', name=_('802.1Q Switching')), + FieldSet( + 'mode', 'vlan_group', 'untagged_vlan', 'tagged_vlans', 'vlan_translation_policy', + name=_('802.1Q Switching') + ), ) nullable_fields = ( - 'parent', 'bridge', 'mtu', 'vrf', 'description', + 'parent', 'bridge', 'mtu', 'vrf', 'description', 'vlan_translation_policy', ) def __init__(self, *args, **kwargs): diff --git a/netbox/virtualization/tables/virtualmachines.py b/netbox/virtualization/tables/virtualmachines.py index 335d1de7d..20cfdd6d1 100644 --- a/netbox/virtualization/tables/virtualmachines.py +++ b/netbox/virtualization/tables/virtualmachines.py @@ -122,7 +122,7 @@ class VMInterfaceTable(BaseInterfaceTable): fields = ( 'pk', 'id', 'name', 'virtual_machine', 'enabled', 'mtu', 'mode', 'description', 'tags', 'vrf', 'primary_mac_address', 'l2vpn', 'tunnel', 'ip_addresses', 'fhrp_groups', 'untagged_vlan', 'tagged_vlans', - 'qinq_svlan', 'created', 'last_updated', + 'qinq_svlan', 'created', 'last_updated', 'vlan_translation_policy', ) default_columns = ('pk', 'name', 'virtual_machine', 'enabled', 'description')