mirror of
https://github.com/netbox-community/netbox.git
synced 2026-02-05 06:46:25 -06:00
Merge branch 'develop' into develop-2.9
This commit is contained in:
@@ -231,6 +231,7 @@ class VMInterfaceFilterSet(BaseFilterSet):
|
||||
mac_address = MultiValueMACAddressFilter(
|
||||
label='MAC address',
|
||||
)
|
||||
tag = TagFilter()
|
||||
|
||||
class Meta:
|
||||
model = VMInterface
|
||||
|
||||
@@ -16,6 +16,14 @@ VIRTUALMACHINE_PRIMARY_IP = """
|
||||
{{ record.primary_ip4.address.ip|default:"" }}
|
||||
"""
|
||||
|
||||
DEVICE_COUNT = """
|
||||
<a href="{% url 'dcim:device_list' %}?cluster_id={{ record.pk }}">{{ value|default:0 }}</a>
|
||||
"""
|
||||
|
||||
VM_COUNT = """
|
||||
<a href="{% url 'virtualization:virtualmachine_list' %}?cluster_id={{ record.pk }}">{{ value|default:0 }}</a>
|
||||
"""
|
||||
|
||||
|
||||
#
|
||||
# Cluster types
|
||||
@@ -66,14 +74,12 @@ class ClusterTable(BaseTable):
|
||||
site = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
device_count = tables.Column(
|
||||
accessor=Accessor('devices__unrestricted__count'),
|
||||
orderable=False,
|
||||
device_count = tables.TemplateColumn(
|
||||
template_code=DEVICE_COUNT,
|
||||
verbose_name='Devices'
|
||||
)
|
||||
vm_count = tables.Column(
|
||||
accessor=Accessor('virtual_machines__unrestricted__count'),
|
||||
orderable=False,
|
||||
vm_count = tables.TemplateColumn(
|
||||
template_code=VM_COUNT,
|
||||
verbose_name='VMs'
|
||||
)
|
||||
tags = TagColumn(
|
||||
|
||||
@@ -9,6 +9,7 @@ from dcim.tables import DeviceTable
|
||||
from extras.views import ObjectConfigContextView
|
||||
from ipam.models import IPAddress, Service
|
||||
from ipam.tables import InterfaceIPAddressTable, InterfaceVLANTable
|
||||
from utilities.utils import get_subquery
|
||||
from utilities.views import (
|
||||
BulkComponentCreateView, BulkDeleteView, BulkEditView, BulkImportView, BulkRenameView, ComponentCreateView,
|
||||
ObjectView, ObjectDeleteView, ObjectEditView, ObjectListView,
|
||||
@@ -80,7 +81,11 @@ class ClusterGroupBulkDeleteView(BulkDeleteView):
|
||||
#
|
||||
|
||||
class ClusterListView(ObjectListView):
|
||||
queryset = Cluster.objects.prefetch_related('type', 'group', 'site', 'tenant')
|
||||
permission_required = 'virtualization.view_cluster'
|
||||
queryset = Cluster.objects.prefetch_related('type', 'group', 'site', 'tenant').annotate(
|
||||
device_count=get_subquery(Device, 'cluster'),
|
||||
vm_count=get_subquery(VirtualMachine, 'cluster')
|
||||
)
|
||||
table = tables.ClusterTable
|
||||
filterset = filters.ClusterFilterSet
|
||||
filterset_form = forms.ClusterFilterForm
|
||||
|
||||
Reference in New Issue
Block a user