Merge branch 'netbox-community:develop' into 11244_filter_badge_missing

This commit is contained in:
Mario 2022-12-27 18:59:49 +01:00 committed by GitHub
commit cf4added02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 1 deletions

View File

@ -506,6 +506,9 @@ class BaseInterfaceTable(NetBoxTable):
verbose_name='Tagged VLANs'
)
def value_ip_addresses(self, value):
return ",".join([str(obj.address) for obj in value.all()])
class InterfaceTable(ModularDeviceComponentTable, BaseInterfaceTable, PathEndpointTable):
device = tables.Column(

View File

@ -33,6 +33,9 @@ class FHRPGroupTable(NetBoxTable):
url_name='ipam:fhrpgroup_list'
)
def value_ip_addresses(self, value):
return ",".join([str(obj.address) for obj in value.all()])
class Meta(NetBoxTable.Meta):
model = FHRPGroup
fields = (

View File

@ -55,6 +55,37 @@
{% plugin_left_page object %}
</div>
<div class="col col-md-6">
<div class="card">
<h5 class="card-header">Allocated Resources</h5>
<div class="card-body">
<table class="table table-hover attr-table">
<tr>
<th scope="row"><i class="mdi mdi-gauge"></i> Virtual CPUs</th>
<td>{{ vcpus_sum|placeholder }}</td>
</tr>
<tr>
<th scope="row"><i class="mdi mdi-chip"></i> Memory</th>
<td>
{% if memory_sum %}
{{ memory_sum|humanize_megabytes }}
{% else %}
{{ ''|placeholder }}
{% endif %}
</td>
</tr>
<tr>
<th scope="row"><i class="mdi mdi-harddisk"></i> Disk Space</th>
<td>
{% if disk_sum %}
{{ disk_sum }} GB
{% else %}
{{ ''|placeholder }}
{% endif %}
</td>
</tr>
</table>
</div>
</div>
{% include 'inc/panels/custom_fields.html' %}
{% include 'inc/panels/tags.html' %}
{% include 'inc/panels/contacts.html' %}

View File

@ -1,6 +1,6 @@
from django.contrib import messages
from django.db import transaction
from django.db.models import Prefetch
from django.db.models import Prefetch, Sum
from django.shortcuts import get_object_or_404, redirect, render
from django.urls import reverse
from django.utils.translation import gettext as _
@ -169,6 +169,9 @@ class ClusterListView(generic.ObjectListView):
class ClusterView(generic.ObjectView):
queryset = Cluster.objects.all()
def get_extra_context(self, request, instance):
return instance.virtual_machines.aggregate(vcpus_sum=Sum('vcpus'), memory_sum=Sum('memory'), disk_sum=Sum('disk'))
@register_model_view(Cluster, 'virtualmachines', path='virtual-machines')
class ClusterVirtualMachinesView(generic.ObjectChildrenView):