mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-22 12:06:53 -06:00
Add summed resource card to cluster view
This commit is contained in:
parent
c7108bb3f7
commit
735fa4aa31
@ -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' %}
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user