mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 01:16:10 +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
|
|
@ -27,7 +27,7 @@ def rbd_source_children(pool):
|
|||
|
||||
|
||||
def volume_details(vol):
|
||||
"""A volume's name, capacity (size), allocation and format, from its XML:
|
||||
"""A volume's name, capacity (size), allocation, format and path, from its XML:
|
||||
one libvirt call, which refreshes the volume as info() does. Logical and
|
||||
iSCSI volumes have no format (None)."""
|
||||
def read(doc):
|
||||
|
|
@ -36,6 +36,7 @@ def volume_details(vol):
|
|||
"size": int(util.get_xpath(doc, "/volume/capacity")),
|
||||
"allocation": int(util.get_xpath(doc, "/volume/allocation")),
|
||||
"type": util.get_xpath(doc, "/volume/target/format/@type"),
|
||||
"path": util.get_xpath(doc, "/volume/target/path"),
|
||||
}
|
||||
return util.get_xml_path(vol.XMLDesc(0), func=read)
|
||||
|
||||
|
|
@ -275,6 +276,11 @@ class wvmStorage(wvmConnect):
|
|||
if path in elsewhere([path]):
|
||||
raise util.InUse(gettext_noop("Volume %(name)s is in use on another compute that shares this storage"), name=name)
|
||||
|
||||
def volume_users(self):
|
||||
"""{path: VM names, sorted} of the paths this host uses (path_users): none for
|
||||
a backing file only another volume is built on."""
|
||||
return {path: sorted(names) for path, names in self.path_users().items()}
|
||||
|
||||
def del_volume(self, name):
|
||||
"""libvirt deletes any volume; one a VM of this host still needs is refused."""
|
||||
vol = self.pool.storageVolLookupByName(name)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue