mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 12:46:49 +00:00
fix(storages): pools are measured when shown, and only on a host's own pages
libvirt measures a pool's size and free space only when the pool is refreshed and keeps those figures until the next refresh. The pool lists read them without a refresh, so they showed a pool's space as of whenever libvirt last refreshed it: two hosts sharing one pool's storage told different free space for it, each its own refresh's. On a test host, a 1 GiB file left libvirt's free space unchanged while df showed 1 GiB less, until the pool was refreshed. get_storages_info refreshes each active pool before reading it; a refresh libvirt refuses (while a volume is cloned in the pool) leaves the last figures, as the pool pages already do. A refresh scans the pool's volumes, so pools are read only where one host's are shown: a host's overview (views.host_pools, its Storage card) and its Storages page and API. The Computes list and the new-VM dialog's host lines, which read every host at once, no longer show pools; Compute.capacity is the vCPUs and memory given.
This commit is contained in:
parent
3a4554bcbf
commit
a0a31cd3f2
10 changed files with 99 additions and 83 deletions
|
|
@ -9,7 +9,6 @@ from libvirt import libvirtError, virConnect
|
|||
from computes.validators import validate_hostname, validate_login, validate_migration_address
|
||||
from vrtManager.connection import connection_manager
|
||||
from vrtManager.hostdetails import wvmHostDetails
|
||||
from vrtManager.storage import wvmStorages
|
||||
|
||||
|
||||
class Compute(Model):
|
||||
|
|
@ -90,10 +89,10 @@ class Compute(Model):
|
|||
|
||||
@cached_property
|
||||
def capacity(self):
|
||||
"""What the host has given its VMs (wvmHostDetails.get_capacity), its
|
||||
vCPUs per CPU, and its active storage pools, the default one first
|
||||
(None when the pools cannot be read); or None when the host cannot be
|
||||
read."""
|
||||
"""What the host has given its VMs (wvmHostDetails.get_capacity) and
|
||||
its vCPUs per CPU; or None when the host cannot be read. Not its
|
||||
pools: their space is measured by a refresh that scans each pool,
|
||||
too slow for pages that read every host (computes.views.host_pools)."""
|
||||
if self.status is not True:
|
||||
return None
|
||||
try:
|
||||
|
|
@ -101,12 +100,6 @@ class Compute(Model):
|
|||
except libvirtError:
|
||||
return None
|
||||
given["ratio"] = given["vcpus"]["all"] / given["cpus"] if given["cpus"] else 0
|
||||
try:
|
||||
storages = wvmStorages(self.hostname, self.login, self.password, self.type)
|
||||
pools = [pool for pool in storages.get_storages_info() if pool["status"]]
|
||||
given["pools"] = sorted(pools, key=lambda pool: (pool["name"] != "default", pool["name"]))
|
||||
except libvirtError:
|
||||
given["pools"] = None
|
||||
return given
|
||||
|
||||
def __str__(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue