mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-10 04:06:47 +00:00
perf(instances): VM lists read each host once, not three calls a VM
A VM list row showed the VM's state, memory, vCPUs and title, read through the VM's own connection object: a lookup by UUID, virDomainGetInfo and the live XML, one after the other for every VM on the page. The lists (Instances, grouped or not, and a compute's VMs) now read each host once: the states in one getAllDomainStats call (the state group only, as the lists' poll; no other group, so a VM busy in the QEMU monitor holds nothing up) and the memory, vCPUs and title from each VM's live XML, which the title already read. Checked on QEMU against virDomainGetInfo for running, paused and shut-off VMs: the same values. A VM gone from its host, or a host that cannot be read or fails its listing, shows its VMs unknown as before. Only the grouped list, a superuser's, prefetches every host's VMs and owners.
This commit is contained in:
parent
37b87839c1
commit
2d0f41ee57
9 changed files with 130 additions and 104 deletions
|
|
@ -9,6 +9,7 @@ from django.urls import reverse
|
|||
from django.utils import timezone
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from instances.models import Instance
|
||||
from instances.utils import read_list_rows
|
||||
from libvirt import libvirtError
|
||||
from logs.audit import audit, changed_fields, snapshot
|
||||
from operations import claims
|
||||
|
|
@ -134,7 +135,8 @@ def instances(request, compute_id):
|
|||
compute = get_object_or_404(Compute, pk=compute_id)
|
||||
|
||||
utils.refresh_instance_database(compute)
|
||||
instances = Instance.objects.filter(compute=compute).order_by("name").prefetch_related("userinstance_set")
|
||||
instances = list(Instance.objects.filter(compute=compute).order_by("name").prefetch_related("userinstance_set"))
|
||||
read_list_rows(instances)
|
||||
|
||||
return render(
|
||||
request, "computes/instances.html",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue