#13428: Misc cleanup

This commit is contained in:
Jeremy Stretch 2024-11-26 09:56:33 -05:00
parent d093b21bc0
commit 9b4b56febc
6 changed files with 26 additions and 9 deletions

View File

@ -7,6 +7,7 @@ from dcim.choices import *
from dcim.constants import * from dcim.constants import *
from dcim.models import * from dcim.models import *
from extras.models import ConfigTemplate from extras.models import ConfigTemplate
from ipam.choices import VLANQinQRoleChoices
from ipam.models import ASN, VLAN, VLANGroup, VRF from ipam.models import ASN, VLAN, VLANGroup, VRF
from netbox.choices import * from netbox.choices import *
from netbox.forms import NetBoxModelBulkEditForm from netbox.forms import NetBoxModelBulkEditForm
@ -1522,6 +1523,16 @@ class InterfaceBulkEditForm(
'available_on_device': '$device', 'available_on_device': '$device',
} }
) )
qinq_svlan = DynamicModelChoiceField(
queryset=VLAN.objects.all(),
required=False,
label=_('Q-in-Q Service VLAN'),
query_params={
'group_id': '$vlan_group',
'available_on_device': '$device',
'qinq_role': VLANQinQRoleChoices.ROLE_SERVICE,
}
)
vrf = DynamicModelChoiceField( vrf = DynamicModelChoiceField(
queryset=VRF.objects.all(), queryset=VRF.objects.all(),
required=False, required=False,
@ -1548,7 +1559,7 @@ class InterfaceBulkEditForm(
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('poe_mode', 'poe_type', name=_('PoE')), FieldSet('poe_mode', 'poe_type', name=_('PoE')),
FieldSet('parent', 'bridge', 'lag', name=_('Related Interfaces')), FieldSet('parent', 'bridge', 'lag', name=_('Related Interfaces')),
FieldSet('mode', 'vlan_group', 'untagged_vlan', name=_('802.1Q Switching')), FieldSet('mode', 'vlan_group', 'untagged_vlan', 'qinq_svlan', name=_('802.1Q Switching')),
FieldSet( FieldSet(
TabbedGroups( TabbedGroups(
FieldSet('tagged_vlans', name=_('Assignment')), FieldSet('tagged_vlans', name=_('Assignment')),
@ -1563,7 +1574,7 @@ class InterfaceBulkEditForm(
nullable_fields = ( nullable_fields = (
'module', 'label', 'parent', 'bridge', 'lag', 'speed', 'duplex', 'wwn', 'vdcs', 'mtu', 'description', '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', 'poe_mode', 'poe_type', 'mode', 'rf_channel', 'rf_channel_frequency', 'rf_channel_width', 'tx_power',
'untagged_vlan', 'tagged_vlans', 'vrf', 'wireless_lans' 'untagged_vlan', 'tagged_vlans', 'qinq_svlan', 'vrf', 'wireless_lans'
) )
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):

View File

@ -1395,7 +1395,7 @@ class InterfaceForm(InterfaceCommonForm, ModularDeviceComponentForm):
'available_on_device': '$device', 'available_on_device': '$device',
} }
) )
qinq_svlan = DynamicModelMultipleChoiceField( qinq_svlan = DynamicModelChoiceField(
queryset=VLAN.objects.all(), queryset=VLAN.objects.all(),
required=False, required=False,
label=_('Q-in-Q Service VLAN'), label=_('Q-in-Q Service VLAN'),

View File

@ -159,8 +159,8 @@ class VLANStatusChoices(ChoiceSet):
class VLANQinQRoleChoices(ChoiceSet): class VLANQinQRoleChoices(ChoiceSet):
ROLE_SERVICE = 's-vlan' ROLE_SERVICE = 'svlan'
ROLE_CUSTOMER = 'c-vlan' ROLE_CUSTOMER = 'cvlan'
CHOICES = [ CHOICES = [
(ROLE_SERVICE, _('Service'), 'blue'), (ROLE_SERVICE, _('Service'), 'blue'),

View File

@ -459,7 +459,7 @@ class VLANImportForm(NetBoxModelImportForm):
) )
qinq_role = CSVChoiceField( qinq_role = CSVChoiceField(
label=_('Q-in-Q role'), label=_('Q-in-Q role'),
choices=VLANStatusChoices, choices=VLANQinQRoleChoices,
required=False, required=False,
help_text=_('Operational status') help_text=_('Operational status')
) )

View File

@ -81,6 +81,12 @@
<th scope="row">{% trans "802.1Q Mode" %}</th> <th scope="row">{% trans "802.1Q Mode" %}</th>
<td>{{ object.get_mode_display|placeholder }}</td> <td>{{ object.get_mode_display|placeholder }}</td>
</tr> </tr>
{% if object.mode == 'q-in-q' %}
<tr>
<th scope="row">{% trans "Q-in-Q SVLAN" %}</th>
<td>{{ object.qinq_svlan|linkify|placeholder }}</td>
</tr>
{% endif %}
<tr> <tr>
<th scope="row">{% trans "Transmit power (dBm)" %}</th> <th scope="row">{% trans "Transmit power (dBm)" %}</th>
<td>{{ object.tx_power|placeholder }}</td> <td>{{ object.tx_power|placeholder }}</td>

View File

@ -72,7 +72,7 @@
{% endif %} {% endif %}
</td> </td>
</tr> </tr>
{% if object.qinq_role == 'c-vlan' %} {% if object.qinq_role == 'cvlan' %}
<tr> <tr>
<th scope="row">{% trans "Q-in-Q SVLAN" %}</th> <th scope="row">{% trans "Q-in-Q SVLAN" %}</th>
<td>{{ object.qinq_svlan|linkify|placeholder }}</td> <td>{{ object.qinq_svlan|linkify|placeholder }}</td>
@ -108,13 +108,13 @@
</h2> </h2>
{% htmx_table 'ipam:prefix_list' vlan_id=object.pk %} {% htmx_table 'ipam:prefix_list' vlan_id=object.pk %}
</div> </div>
{% if object.qinq_role == 's-vlan' %} {% if object.qinq_role == 'svlan' %}
<div class="card"> <div class="card">
<h2 class="card-header"> <h2 class="card-header">
{% trans "Customer VLANs" %} {% trans "Customer VLANs" %}
{% if perms.ipam.add_vlan %} {% if perms.ipam.add_vlan %}
<div class="card-actions"> <div class="card-actions">
<a href="{% url 'ipam:vlan_add' %}?qinq_role=c-vlan&qinq_svlan={{ object.pk }}" class="btn btn-ghost-primary btn-sm"> <a href="{% url 'ipam:vlan_add' %}?qinq_role=cvlan&qinq_svlan={{ object.pk }}" class="btn btn-ghost-primary btn-sm">
<i class="mdi mdi-plus-thick" aria-hidden="true"></i> {% trans "Add a VLAN" %} <i class="mdi mdi-plus-thick" aria-hidden="true"></i> {% trans "Add a VLAN" %}
</a> </a>
</div> </div>