mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-21 19:47:20 -06:00
Merge pull request #974 from marc-us/develop
Filter on mac address on interface
This commit is contained in:
commit
fb6cfa45fd
@ -409,6 +409,10 @@ class InterfaceFilter(django_filters.FilterSet):
|
|||||||
method='filter_type',
|
method='filter_type',
|
||||||
label='Interface type',
|
label='Interface type',
|
||||||
)
|
)
|
||||||
|
mac_address = django_filters.CharFilter(
|
||||||
|
method='_mac_address',
|
||||||
|
label='MAC address',
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Interface
|
model = Interface
|
||||||
@ -424,6 +428,15 @@ class InterfaceFilter(django_filters.FilterSet):
|
|||||||
return queryset.filter(form_factor=IFACE_FF_LAG)
|
return queryset.filter(form_factor=IFACE_FF_LAG)
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
|
def _mac_address(self, queryset, name, value):
|
||||||
|
value = value.strip()
|
||||||
|
if not value:
|
||||||
|
return queryset
|
||||||
|
try:
|
||||||
|
return queryset.filter(mac_address=value)
|
||||||
|
except AddrFormatError:
|
||||||
|
return queryset.none()
|
||||||
|
|
||||||
|
|
||||||
class ConsoleConnectionFilter(django_filters.FilterSet):
|
class ConsoleConnectionFilter(django_filters.FilterSet):
|
||||||
site = django_filters.CharFilter(
|
site = django_filters.CharFilter(
|
||||||
|
Loading…
Reference in New Issue
Block a user