mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Enable attachment of wireless interfaces to SSIDs
This commit is contained in:
@ -16,6 +16,7 @@ from utilities.forms import (
|
||||
SlugField, StaticSelect,
|
||||
)
|
||||
from virtualization.models import Cluster, ClusterGroup
|
||||
from wireless.models import SSID
|
||||
from .common import InterfaceCommonForm
|
||||
|
||||
__all__ = (
|
||||
@ -1068,6 +1069,11 @@ class InterfaceForm(BootstrapMixin, InterfaceCommonForm, CustomFieldModelForm):
|
||||
'type': 'lag',
|
||||
}
|
||||
)
|
||||
ssids = DynamicModelMultipleChoiceField(
|
||||
queryset=SSID.objects.all(),
|
||||
required=False,
|
||||
label='SSIDs'
|
||||
)
|
||||
vlan_group = DynamicModelChoiceField(
|
||||
queryset=VLANGroup.objects.all(),
|
||||
required=False,
|
||||
@ -1098,8 +1104,8 @@ class InterfaceForm(BootstrapMixin, InterfaceCommonForm, CustomFieldModelForm):
|
||||
model = Interface
|
||||
fields = [
|
||||
'device', 'name', 'label', 'type', 'enabled', 'parent', 'lag', 'mac_address', 'wwn', 'mtu', 'mgmt_only',
|
||||
'mark_connected', 'description', 'mode', 'rf_channel', 'rf_channel_width', 'untagged_vlan', 'tagged_vlans',
|
||||
'tags',
|
||||
'mark_connected', 'description', 'mode', 'rf_channel', 'rf_channel_width', 'ssids', 'untagged_vlan',
|
||||
'tagged_vlans', 'tags',
|
||||
]
|
||||
widgets = {
|
||||
'device': forms.HiddenInput(),
|
||||
|
@ -4,6 +4,7 @@ from django.db import migrations, models
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('wireless', '__first__'),
|
||||
('dcim', '0135_location_tenant'),
|
||||
]
|
||||
|
||||
@ -18,4 +19,9 @@ class Migration(migrations.Migration):
|
||||
name='rf_channel_width',
|
||||
field=models.PositiveSmallIntegerField(blank=True, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='interface',
|
||||
name='ssids',
|
||||
field=models.ManyToManyField(blank=True, related_name='interfaces', to='wireless.SSID'),
|
||||
),
|
||||
]
|
||||
|
@ -529,6 +529,12 @@ class Interface(ComponentModel, BaseInterface, CableTermination, PathEndpoint):
|
||||
null=True,
|
||||
verbose_name='Channel width'
|
||||
)
|
||||
ssids = models.ManyToManyField(
|
||||
to='wireless.SSID',
|
||||
related_name='interfaces',
|
||||
blank=True,
|
||||
verbose_name='SSIDs'
|
||||
)
|
||||
untagged_vlan = models.ForeignKey(
|
||||
to='ipam.VLAN',
|
||||
on_delete=models.SET_NULL,
|
||||
|
@ -258,6 +258,33 @@
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if object.is_wireless %}
|
||||
<div class="card">
|
||||
<h5 class="card-header">SSIDs</h5>
|
||||
<div class="card-body">
|
||||
<table class="table table-hover table-headings">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for ssid in object.ssids.all %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{{ ssid.get_absolute_url }}">{{ ssid.name }}</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
<tr>
|
||||
<td colspan="3" class="text-muted">None</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if object.is_lag %}
|
||||
<div class="card">
|
||||
<h5 class="card-header">LAG Members</h5>
|
||||
|
@ -36,6 +36,7 @@
|
||||
</div>
|
||||
{% render_field form.rf_channel %}
|
||||
{% render_field form.rf_channel_width %}
|
||||
{% render_field form.ssids %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
@ -9,7 +9,6 @@ class Migration(migrations.Migration):
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('dcim', '0136_wireless'),
|
||||
('extras', '0062_clear_secrets_changelog'),
|
||||
('ipam', '0050_iprange'),
|
||||
]
|
||||
|
@ -1,7 +1,8 @@
|
||||
from django.db import models
|
||||
from django.urls import reverse
|
||||
|
||||
from extras.utils import extras_features
|
||||
from netbox.models import PrimaryModel
|
||||
from netbox.models import BigIDModel, PrimaryModel
|
||||
from utilities.querysets import RestrictedQuerySet
|
||||
|
||||
__all__ = (
|
||||
@ -9,6 +10,10 @@ __all__ = (
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# SSIDs
|
||||
#
|
||||
|
||||
@extras_features('custom_fields', 'custom_links', 'export_templates', 'tags', 'webhooks')
|
||||
class SSID(PrimaryModel):
|
||||
"""
|
||||
@ -38,3 +43,6 @@ class SSID(PrimaryModel):
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('wireless:ssid', args=[self.pk])
|
||||
|
@ -10,9 +10,8 @@ __all__ = (
|
||||
|
||||
class SSIDTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
id = tables.Column(
|
||||
linkify=True,
|
||||
verbose_name='ID'
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
tags = TagColumn(
|
||||
url_name='dcim:cable_list'
|
||||
@ -20,5 +19,5 @@ class SSIDTable(BaseTable):
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
model = SSID
|
||||
fields = ('pk', 'id', 'name', 'description', 'vlan')
|
||||
fields = ('pk', 'name', 'description', 'vlan')
|
||||
default_columns = ('pk', 'name', 'description', 'vlan')
|
||||
|
@ -15,7 +15,7 @@ class SSIDListView(generic.ObjectListView):
|
||||
|
||||
|
||||
class SSIDView(generic.ObjectView):
|
||||
queryset = SSID.objects.prefetch_related('power_panel', 'rack')
|
||||
queryset = SSID.objects.all()
|
||||
|
||||
|
||||
class SSIDEditView(generic.ObjectEditView):
|
||||
@ -34,13 +34,13 @@ class SSIDBulkImportView(generic.BulkImportView):
|
||||
|
||||
|
||||
class SSIDBulkEditView(generic.BulkEditView):
|
||||
queryset = SSID.objects.prefetch_related('power_panel', 'rack')
|
||||
queryset = SSID.objects.all()
|
||||
filterset = filtersets.SSIDFilterSet
|
||||
table = tables.SSIDTable
|
||||
form = forms.SSIDBulkEditForm
|
||||
|
||||
|
||||
class SSIDBulkDeleteView(generic.BulkDeleteView):
|
||||
queryset = SSID.objects.prefetch_related('power_panel', 'rack')
|
||||
queryset = SSID.objects.all()
|
||||
filterset = filtersets.SSIDFilterSet
|
||||
table = tables.SSIDTable
|
||||
|
Reference in New Issue
Block a user