mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
feat(storages): the pool page tells which VMs use each volume
A volume left behind (a disk kept when its VM was deleted, an old image) was not told apart from one a VM needs until its deletion was refused. The pool page now has a "Used by" column: the VMs of this host whose disks, UEFI variables, saved state or snapshots are the volume or are built on it, "In use" for one only another volume is built on, else "Not used on this host"; buttons list each kind, and a VM's name finds its volumes. Its deletion still asks the other hosts, as one sharing the storage may use it. When the host's VMs cannot be read the page lists the volumes without the column. The scan that refuses deleting a used volume now also counts a VM's UEFI variables file and a snapshot's block device, and reads each VM once.
This commit is contained in:
parent
dc5b1dbb2a
commit
aeef837afa
12 changed files with 248 additions and 88 deletions
|
|
@ -232,8 +232,14 @@ def storage(request, compute_id, pool):
|
|||
# read only for the page: every action above redirects, but a refused new volume
|
||||
# first: it refreshes the pool, and libvirt measures a pool's space only then
|
||||
volumes = conn.update_volumes() if state else None
|
||||
users = None
|
||||
if volumes:
|
||||
# which VMs of this host use each volume; the page lists them without it when it cannot be read
|
||||
with contextlib.suppress(libvirtError):
|
||||
users = conn.volume_users()
|
||||
for volume in volumes or []:
|
||||
volume["iso"] = is_iso(volume["name"])
|
||||
volume["users"] = users.get(volume["path"]) if users is not None else None
|
||||
try:
|
||||
size, free = conn.get_size()
|
||||
status = conn.get_status()
|
||||
|
|
@ -251,6 +257,7 @@ def storage(request, compute_id, pool):
|
|||
"form": form,
|
||||
"state": state,
|
||||
"volumes": volumes,
|
||||
"users_read": users is not None,
|
||||
"size": size,
|
||||
"free": free,
|
||||
"used": used,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue