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

feat(instances): the new-VM dialog shows what each host has given its VMs

Under each host's CPU and memory load, the dialog shows one line:

  Given to VMs: 24 vCPUs (1.5:1), 48.0 GB memory.
  Pool default: 120.0 GB free.

The line is read when the dialog opens, from computes/<id>/capacity/,
as plain text, so the VM list itself reads no VM definitions. The CPU
bars and the lines share one queue, host by host and two reads at a
time, as each read holds a worker. A host that cannot be read says so.

Compute.capacity now also gives the vCPUs per CPU and its pools with
the default one first, so the Computes page and the dialog share them.
This commit is contained in:
catborise 2026-10-25 12:41:55 +03:00
parent 3416ef6503
commit 8d76744c74
8 changed files with 136 additions and 74 deletions

View file

@ -90,16 +90,19 @@ class Compute(Model):
@cached_property
def capacity(self):
"""What the host has given its VMs (wvmHostDetails.get_capacity) and
its active storage pools, or None when it cannot be read."""
"""What the host has given its VMs (wvmHostDetails.get_capacity), its
vCPUs per CPU, and its active storage pools, the default one first; or
None when it cannot be read."""
if self.status is not True:
return None
try:
given = self.proxy.get_capacity()
storages = wvmStorages(self.hostname, self.login, self.password, self.type)
given["pools"] = [pool for pool in storages.get_storages_info() if pool["status"]]
pools = [pool for pool in storages.get_storages_info() if pool["status"]]
except libvirtError:
return None
given["ratio"] = given["vcpus"]["all"] / given["cpus"] if given["cpus"] else 0
given["pools"] = sorted(pools, key=lambda pool: (pool["name"] != "default", pool["name"]))
return given
def __str__(self):