mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-09 11:46:49 +00:00
perf(instances): a VM page does not wait for the guest agent's addresses
A running VM's page read its addresses while it rendered: the guest agent, when its channel is connected but it does not answer, holds the page (and a gunicorn worker) for its whole 10 s timeout, on every load. The page now shows them once it has loaded: vm_addresses.js asks the new instances/<pk>/addresses/ for each NIC's addresses and fills the header's IPv4 and each network card's IPv4 and IPv6.
This commit is contained in:
parent
bf736942eb
commit
aab8dbf1df
18 changed files with 600 additions and 449 deletions
|
|
@ -2,6 +2,7 @@ from computes.models import Compute
|
|||
from django.conf import settings
|
||||
from instances.models import Flavor, Instance
|
||||
from instances.utils import nic_macs
|
||||
from libvirt import libvirtError
|
||||
from rest_framework import serializers
|
||||
|
||||
|
||||
|
|
@ -12,6 +13,17 @@ class InstanceSerializer(serializers.ModelSerializer):
|
|||
|
||||
|
||||
class InstanceDetailsSerializer(serializers.ModelSerializer):
|
||||
networks = serializers.SerializerMethodField()
|
||||
|
||||
def get_networks(self, instance) -> list[dict]:
|
||||
"""Each NIC with its addresses (None: none known), which the VM page
|
||||
reads after it loads (views.nic_addresses)."""
|
||||
try:
|
||||
found = instance.proxy.get_addresses()
|
||||
except libvirtError:
|
||||
found = {}
|
||||
return [{**nic, **dict(zip(("ipv4", "ipv6"), found.get(nic["mac"], (None, None))))} for nic in instance.networks]
|
||||
|
||||
def get_fields(self):
|
||||
fields = super().get_fields()
|
||||
# the host's ISO images are a superuser's, as on the VM page
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue