mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-24 08:25:17 -06:00
Merge branch '11478-fix-cabling-interface-display' of https://github.com/netbox-community/netbox into 11478-fix-cabling-interface-display
This commit is contained in:
commit
e35d658d74
@ -1470,7 +1470,7 @@ class InterfaceFilterSet(
|
||||
label=_('Device'),
|
||||
)
|
||||
device_id = MultiValueNumberFilter(
|
||||
method='filter_device_id',
|
||||
method='filter_device',
|
||||
field_name='pk',
|
||||
label=_('Device (ID)'),
|
||||
)
|
||||
@ -1541,22 +1541,16 @@ class InterfaceFilterSet(
|
||||
]
|
||||
|
||||
def filter_device(self, queryset, name, value):
|
||||
try:
|
||||
devices = Device.objects.filter(**{'{}__in'.format(name): value})
|
||||
vc_interface_ids = []
|
||||
for device in devices:
|
||||
vc_interface_ids.extend(device.vc_interfaces().values_list('id', flat=True))
|
||||
return queryset.filter(pk__in=vc_interface_ids)
|
||||
except Device.DoesNotExist:
|
||||
return queryset.none()
|
||||
|
||||
def filter_device_id(self, queryset, name, id_list):
|
||||
# Include interfaces belonging to peer virtual chassis members
|
||||
vc_interface_ids = []
|
||||
try:
|
||||
devices = Device.objects.filter(pk__in=id_list)
|
||||
devices = Device.objects.filter(**{'{}__in'.format(name): value})
|
||||
for device in devices:
|
||||
# Hack to show all VC member interfaces when requested
|
||||
if self.request is not None and 'vc_interfaces' in self.request.GET.keys():
|
||||
vc_interface_ids += device.vc_interfaces(if_master=False).values_list('id', flat=True)
|
||||
else:
|
||||
vc_interface_ids.extend(device.vc_interfaces().values_list('id', flat=True))
|
||||
return queryset.filter(pk__in=vc_interface_ids)
|
||||
except Device.DoesNotExist:
|
||||
return queryset.none()
|
||||
|
@ -1108,6 +1108,7 @@ class InterfaceForm(InterfaceCommonForm, ModularDeviceComponentForm):
|
||||
label=_('Parent interface'),
|
||||
query_params={
|
||||
'device_id': '$device',
|
||||
'vc_interfaces': 'all',
|
||||
}
|
||||
)
|
||||
bridge = DynamicModelChoiceField(
|
||||
@ -1116,6 +1117,7 @@ class InterfaceForm(InterfaceCommonForm, ModularDeviceComponentForm):
|
||||
label=_('Bridged interface'),
|
||||
query_params={
|
||||
'device_id': '$device',
|
||||
'vc_interfaces': 'all',
|
||||
}
|
||||
)
|
||||
lag = DynamicModelChoiceField(
|
||||
@ -1124,6 +1126,7 @@ class InterfaceForm(InterfaceCommonForm, ModularDeviceComponentForm):
|
||||
label=_('LAG interface'),
|
||||
query_params={
|
||||
'device_id': '$device',
|
||||
'vc_interfaces': 'all',
|
||||
'type': 'lag',
|
||||
}
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user