diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py index 741194712..35ab0ee20 100644 --- a/netbox/dcim/views.py +++ b/netbox/dcim/views.py @@ -1807,10 +1807,7 @@ class DeviceView(generic.ObjectView): else: vc_members = [] - services = Service.objects.restrict(request.user, 'view').filter(device=instance) - return { - 'services': services, 'vc_members': vc_members, 'svg_extra': f'highlight=id:{instance.pk}' } diff --git a/netbox/ipam/views.py b/netbox/ipam/views.py index b7cd72d67..e3245ef39 100644 --- a/netbox/ipam/views.py +++ b/netbox/ipam/views.py @@ -716,28 +716,10 @@ class IPAddressView(generic.ObjectView): related_ips_table = tables.IPAddressTable(related_ips, orderable=False) related_ips_table.configure(request) - # Find services belonging to the IP - service_filter = Q(ipaddresses=instance) - - # Find services listening on all IPs on the assigned device/vm - try: - if instance.assigned_object and instance.assigned_object.parent_object: - parent_object = instance.assigned_object.parent_object - - if isinstance(parent_object, VirtualMachine): - service_filter |= (Q(virtual_machine=parent_object) & Q(ipaddresses=None)) - elif isinstance(parent_object, Device): - service_filter |= (Q(device=parent_object) & Q(ipaddresses=None)) - except AttributeError: - pass - - services = Service.objects.restrict(request.user, 'view').filter(service_filter) - return { 'parent_prefixes_table': parent_prefixes_table, 'duplicate_ips_table': duplicate_ips_table, 'related_ips_table': related_ips_table, - 'services': services, } diff --git a/netbox/templates/dcim/device.html b/netbox/templates/dcim/device.html index 6a0d00d6d..3c2cc6299 100644 --- a/netbox/templates/dcim/device.html +++ b/netbox/templates/dcim/device.html @@ -282,7 +282,20 @@ {% endif %} - {% include 'inc/panels/services.html' %} +
+
Services
+
+ {% if perms.ipam.add_service %} + + {% endif %} +
{% include 'inc/panels/contacts.html' %} {% include 'inc/panels/image_attachments.html' %} {% if object.rack and object.position %} diff --git a/netbox/templates/inc/panels/services.html b/netbox/templates/inc/panels/services.html deleted file mode 100644 index b7109f497..000000000 --- a/netbox/templates/inc/panels/services.html +++ /dev/null @@ -1,50 +0,0 @@ -
-
Services
-
- {% if services %} - - {% for service in services %} - - - - - - - - - {% endfor %} -
{{ service|linkify:"name" }}{{ service.get_protocol_display }}{{ service.port_list }} - {% for ip in service.ipaddresses.all %} - {{ ip.address.ip }}
- {% empty %} - All IPs - {% endfor %} -
{{ service.description }} - - - - {% if perms.ipam.change_service %} - - - - {% endif %} - {% if perms.ipam.delete_service %} - - - - {% endif %} -
- {% else %} -
None
- {% endif %} -
- {% if perms.ipam.add_service %} - {% with object|meta:"model_name" as object_type %} - - {% endwith %} - {% endif %} -
diff --git a/netbox/templates/ipam/ipaddress.html b/netbox/templates/ipam/ipaddress.html index 74c1131ca..c649f1dad 100644 --- a/netbox/templates/ipam/ipaddress.html +++ b/netbox/templates/ipam/ipaddress.html @@ -117,14 +117,19 @@ {% include 'inc/panel_table.html' with table=duplicate_ips_table heading='Duplicate IPs' panel_class='danger' %} {% endif %} {% include 'inc/panel_table.html' with table=related_ips_table heading='Related IPs' %} - {% include 'inc/panels/services.html' %} +
+
Services
+
+
{% plugin_right_page object %} -
-
- {% plugin_full_width_page object %} -
+
+ {% plugin_full_width_page object %} +
{% endblock %} diff --git a/netbox/templates/virtualization/virtualmachine.html b/netbox/templates/virtualization/virtualmachine.html index 9b5708486..5098a2f8f 100644 --- a/netbox/templates/virtualization/virtualmachine.html +++ b/netbox/templates/virtualization/virtualmachine.html @@ -144,7 +144,20 @@ - {% include 'inc/panels/services.html' %} +
+
Services
+
+ {% if perms.ipam.add_service %} + + {% endif %} +
{% include 'inc/panels/contacts.html' %} {% plugin_right_page object %} diff --git a/netbox/virtualization/views.py b/netbox/virtualization/views.py index d7a4856f2..7feff18d5 100644 --- a/netbox/virtualization/views.py +++ b/netbox/virtualization/views.py @@ -327,32 +327,7 @@ class VirtualMachineListView(generic.ObjectListView): @register_model_view(VirtualMachine) class VirtualMachineView(generic.ObjectView): - queryset = VirtualMachine.objects.prefetch_related('tenant__group') - - def get_extra_context(self, request, instance): - # Interfaces - vminterfaces = VMInterface.objects.restrict(request.user, 'view').filter( - virtual_machine=instance - ).prefetch_related( - Prefetch('ip_addresses', queryset=IPAddress.objects.restrict(request.user)) - ) - vminterface_table = tables.VirtualMachineVMInterfaceTable(vminterfaces, user=request.user, orderable=False) - if request.user.has_perm('virtualization.change_vminterface') or \ - request.user.has_perm('virtualization.delete_vminterface'): - vminterface_table.columns.show('pk') - - # Services - services = Service.objects.restrict(request.user, 'view').filter( - virtual_machine=instance - ).prefetch_related( - Prefetch('ipaddresses', queryset=IPAddress.objects.restrict(request.user)), - 'virtual_machine' - ) - - return { - 'vminterface_table': vminterface_table, - 'services': services, - } + queryset = VirtualMachine.objects.all() @register_model_view(VirtualMachine, 'interfaces')