Closes #105: Interface groups (#919)

* Initial work on interface groups

* Simplify to a single LAG form factor

* Correct interface serializer

* Allow for bulk editing of interface LAG

* Additional LAG interface validation

* Fixed API tests
This commit is contained in:
Jeremy Stretch
2017-02-27 16:52:13 -05:00
committed by GitHub
parent dddeebb882
commit 9847b5187f
13 changed files with 247 additions and 52 deletions

View File

@@ -7,8 +7,9 @@ from extras.filters import CustomFieldFilterSet
from tenancy.models import Tenant
from utilities.filters import NullableModelMultipleChoiceFilter
from .models import (
ConsolePort, ConsoleServerPort, Device, DeviceRole, DeviceType, Interface, InterfaceConnection, Manufacturer,
Platform, PowerOutlet, PowerPort, Rack, RackGroup, RackReservation, RackRole, Site,
ConsolePort, ConsoleServerPort, Device, DeviceRole, DeviceType, IFACE_FF_LAG, Interface, InterfaceConnection,
Manufacturer, Platform, PowerOutlet, PowerPort, Rack, RackGroup, RackReservation, RackRole, Site,
VIRTUAL_IFACE_TYPES,
)
@@ -374,11 +375,25 @@ class InterfaceFilter(django_filters.FilterSet):
to_field_name='name',
label='Device (name)',
)
type = django_filters.MethodFilter(
action='filter_type',
label='Interface type',
)
class Meta:
model = Interface
fields = ['name']
def filter_type(self, queryset, value):
value = value.strip().lower()
if value == 'physical':
return queryset.exclude(form_factor__in=VIRTUAL_IFACE_TYPES)
elif value == 'virtual':
return queryset.filter(form_factor__in=VIRTUAL_IFACE_TYPES)
elif value == 'lag':
return queryset.filter(form_factor=IFACE_FF_LAG)
return queryset
class ConsoleConnectionFilter(django_filters.FilterSet):
site = django_filters.MethodFilter(