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

fix(instances): the REST API's list of all VMs reads the hosts first

/api/v1/instances/ listed the panel's VM records without asking the
hosts: a VM undefined or renamed with virsh stayed there as it was, and
one defined outside never appeared, until someone opened a web VM list
(the per-host API list already read its host). It now reads the hosts
it lists first, as the VM list does: all at once, one that does not
answer left as last read. Seen live: a VM defined with virsh appears,
and is gone once undefined.
This commit is contained in:
catborise 2026-11-13 15:24:43 +03:00
parent cdc7468af3
commit 3dfdd529b2
2 changed files with 47 additions and 0 deletions

View file

@ -8,7 +8,9 @@ from django.urls import reverse
from django.utils.translation import gettext as _
from instances.jobs import MIGRATE_OPTIONS
from instances.models import Flavor, Instance
from instances.utils import host_domain_states
from instances.views import (
_listed_computes,
force_off,
get_instance,
powercycle,
@ -56,6 +58,12 @@ class InstancesViewSet(viewsets.ViewSet):
lookup_value_converter = "int"
def list(self, request):
# as the VM list: the hosts read first (all at once, one that does not answer
# left as last read), so that VMs added, renamed or removed outside are seen
computes = _listed_computes(request.user, list(Compute.objects.all()))
host_domain_states(computes)
for compute in computes:
utils.refresh_instance_database(compute)
if request.user.is_superuser or request.user.has_perm(
"instances.view_instances"