mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-10 04:06:47 +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
|
|
@ -69,31 +69,35 @@ def pool(volumes, refresh_error=False, list_error=False):
|
|||
|
||||
|
||||
class IsoListTestCase(unittest.TestCase):
|
||||
"""The CD-ROM choices are the .iso volumes of the active pools, refreshed
|
||||
so that an image copied in by hand shows up."""
|
||||
"""The CD-ROM choices are the .iso volumes libvirt knows in the active
|
||||
pools; the pools are read again only when asked."""
|
||||
|
||||
def iso(self, *pools):
|
||||
def wvm(self, *pools):
|
||||
inst = wvmInstance.__new__(wvmInstance)
|
||||
inst.wvm = MagicMock()
|
||||
inst.wvm.listAllStoragePools.return_value = list(pools)
|
||||
return inst, inst.get_iso_media()
|
||||
return inst
|
||||
|
||||
def test_iso_volumes_of_the_active_pools(self):
|
||||
def test_iso_volumes_of_the_active_pools_without_a_refresh(self):
|
||||
a, b = pool(["a.iso", "disk.qcow2"]), pool(["B.ISO"])
|
||||
inst, iso = self.iso(a, b)
|
||||
self.assertEqual(iso, ["a.iso", "B.ISO"])
|
||||
inst = self.wvm(a, b)
|
||||
self.assertEqual(inst.get_iso_media(), ["a.iso", "B.ISO"])
|
||||
inst.wvm.listAllStoragePools.assert_called_once_with(VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE)
|
||||
a.refresh.assert_not_called()
|
||||
b.refresh.assert_not_called()
|
||||
|
||||
def test_a_pool_stopped_meanwhile_is_skipped(self):
|
||||
inst = self.wvm(pool([], list_error=True), pool(["b.iso"]))
|
||||
self.assertEqual(inst.get_iso_media(), ["b.iso"])
|
||||
|
||||
def test_refresh_reads_every_active_pool_again(self):
|
||||
a, b = pool([], refresh_error=True), pool([])
|
||||
inst = self.wvm(a, b)
|
||||
inst.refresh_iso_pools()
|
||||
inst.wvm.listAllStoragePools.assert_called_once_with(VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE)
|
||||
a.refresh.assert_called_once_with(0)
|
||||
b.refresh.assert_called_once_with(0)
|
||||
|
||||
def test_a_failed_refresh_still_lists_the_pool(self):
|
||||
_, iso = self.iso(pool(["a.iso"], refresh_error=True))
|
||||
self.assertEqual(iso, ["a.iso"])
|
||||
|
||||
def test_a_pool_stopped_meanwhile_is_skipped(self):
|
||||
_, iso = self.iso(pool([], list_error=True), pool(["b.iso"]))
|
||||
self.assertEqual(iso, ["b.iso"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue