1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fixes #9575: Add exception handling to services (#9586)

This commit is contained in:
Hunter Johnston
2022-06-23 14:11:59 -04:00
committed by GitHub
parent 6cb8b9110e
commit afec53cea3

View File

@ -680,6 +680,7 @@ class IPAddressView(generic.ObjectView):
service_filter = Q(ipaddresses=instance) service_filter = Q(ipaddresses=instance)
# Find services listening on all IPs on the assigned device/vm # Find services listening on all IPs on the assigned device/vm
try:
if instance.assigned_object and instance.assigned_object.parent_object: if instance.assigned_object and instance.assigned_object.parent_object:
parent_object = instance.assigned_object.parent_object parent_object = instance.assigned_object.parent_object
@ -687,6 +688,8 @@ class IPAddressView(generic.ObjectView):
service_filter |= (Q(virtual_machine=parent_object) & Q(ipaddresses=None)) service_filter |= (Q(virtual_machine=parent_object) & Q(ipaddresses=None))
elif isinstance(parent_object, Device): elif isinstance(parent_object, Device):
service_filter |= (Q(device=parent_object) & Q(ipaddresses=None)) service_filter |= (Q(device=parent_object) & Q(ipaddresses=None))
except AttributeError:
pass
services = Service.objects.restrict(request.user, 'view').filter(service_filter) services = Service.objects.restrict(request.user, 'view').filter(service_filter)