1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 17:36:05 +00:00

feat(computes): a host's Instances page is the VM list of its VMs

A host's Instances page had a table of its own, older than the VM list:
no state filter, no tag filter, no bulk bar, a two-line Name/Description
head and a round green button for a new VM. It now shows the VM list
itself, of that host's VMs and without a host column, beside the host's
tabs, Bulk Migrate and New VM. The bulk bar sends back to the list it
was used on.
This commit is contained in:
catborise 2026-11-21 20:17:07 +03:00
parent 59db1f5515
commit 383cbe89a6
16 changed files with 192 additions and 247 deletions

View file

@ -24,6 +24,7 @@ from django.views.decorators.http import require_POST
from webvirtcloud.middleware import error_text
from instances.models import Instance
from instances.utils import read_list_rows, vm_states
from instances.views import vm_list_context
from libvirt import libvirtError
from logs.audit import audit, changed_fields, snapshot
from operations import claims, jobs
@ -367,13 +368,13 @@ def instances(request, compute_id):
# read first: the poll's first answer then tells a change made while the page was read
states = vm_states(request.user, [compute])
utils.refresh_instance_database(compute)
instances = list(Instance.objects.filter(compute=compute).order_by("name").prefetch_related("userinstance_set", "tags"))
instances = list(Instance.objects.filter(compute=compute).order_by("name").prefetch_related("userinstance_set__user", "tags"))
read_list_rows(instances, [compute])
# the VM list's own list, of this host's VMs
return render(
request, "computes/instances.html",
{"compute": compute, "instances": instances, "job_resource": claims.compute_key(compute.id),
"states_url": reverse("instances:states") + f"?compute={compute.id}", "vm_states": states},
{"compute": compute, "one_host": compute, "show_hosts": True, "job_resource": claims.compute_key(compute.id),
**vm_list_context(request, instances, reverse("instances:states") + f"?compute={compute.id}", states)},
)