mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-09 03:36:48 +00:00
perf(instances): the VM page lists ISO images without reading every pool
The VM page refreshed every active storage pool to list the ISO images for its CD-ROM drives. A pool holding large disk images took up to seconds to refresh, most of the page's time, on every page load. The page now lists the ISO images libvirt already knows. Images uploaded through the panel are known at once. For an image copied to a pool by hand, the Removable media section has a Refresh ISO list button that refreshes the active pools and returns to the page.
This commit is contained in:
parent
37905a0b75
commit
d5d054de71
6 changed files with 52 additions and 19 deletions
|
|
@ -1713,12 +1713,18 @@ class wvmInstance(wvmConnect):
|
|||
if active:
|
||||
self.instance.blockResize(disk["path"], disk["size_new"], VIR_DOMAIN_BLOCK_RESIZE_BYTES)
|
||||
|
||||
def refresh_iso_pools(self):
|
||||
"""Refresh the active pools, so that an image copied to one by hand
|
||||
is listed by get_iso_media."""
|
||||
for pool in self.wvm.listAllStoragePools(VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE):
|
||||
with contextlib.suppress(libvirtError): # stopped or removed meanwhile
|
||||
pool.refresh(0)
|
||||
|
||||
def get_iso_media(self):
|
||||
"""The .iso volumes libvirt knows in the active pools; one copied in
|
||||
by hand is known after refresh_iso_pools."""
|
||||
iso = []
|
||||
for pool in self.wvm.listAllStoragePools(VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE):
|
||||
# refreshed so that an image copied to the pool by hand shows up
|
||||
with contextlib.suppress(libvirtError):
|
||||
pool.refresh(0)
|
||||
try:
|
||||
names = pool.listVolumes()
|
||||
except libvirtError: # stopped or removed meanwhile
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue