File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,37 @@ <h5 class="card-header">
5555 {% plugin_left_page object %}
5656 </ div >
5757 < div class ="col col-md-6 ">
58+ < div class ="card ">
59+ < h5 class ="card-header "> Allocated Resources</ h5 >
60+ < div class ="card-body ">
61+ < table class ="table table-hover attr-table ">
62+ < tr >
63+ < th scope ="row "> < i class ="mdi mdi-gauge "> </ i > Virtual CPUs</ th >
64+ < td > {{ vcpus_sum|placeholder }}</ td >
65+ </ tr >
66+ < tr >
67+ < th scope ="row "> < i class ="mdi mdi-chip "> </ i > Memory</ th >
68+ < td >
69+ {% if memory_sum %}
70+ {{ memory_sum|humanize_megabytes }}
71+ {% else %}
72+ {{ ''|placeholder }}
73+ {% endif %}
74+ </ td >
75+ </ tr >
76+ < tr >
77+ < th scope ="row "> < i class ="mdi mdi-harddisk "> </ i > Disk Space</ th >
78+ < td >
79+ {% if disk_sum %}
80+ {{ disk_sum }} GB
81+ {% else %}
82+ {{ ''|placeholder }}
83+ {% endif %}
84+ </ td >
85+ </ tr >
86+ </ table >
87+ </ div >
88+ </ div >
5889 {% include 'inc/panels/custom_fields.html' %}
5990 {% include 'inc/panels/tags.html' %}
6091 {% include 'inc/panels/contacts.html' %}
Original file line number Diff line number Diff line change 11from django .contrib import messages
22from django .db import transaction
3- from django .db .models import Prefetch
3+ from django .db .models import Prefetch , Sum
44from django .shortcuts import get_object_or_404 , redirect , render
55from django .urls import reverse
66from django .utils .translation import gettext as _
@@ -169,6 +169,9 @@ class ClusterListView(generic.ObjectListView):
169169class ClusterView (generic .ObjectView ):
170170 queryset = Cluster .objects .all ()
171171
172+ def get_extra_context (self , request , instance ):
173+ return instance .virtual_machines .aggregate (vcpus_sum = Sum ('vcpus' ), memory_sum = Sum ('memory' ), disk_sum = Sum ('disk' ))
174+
172175
173176@register_model_view (Cluster , 'virtualmachines' , path = 'virtual-machines' )
174177class ClusterVirtualMachinesView (generic .ObjectChildrenView ):
You can’t perform that action at this time.
0 commit comments