1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-11 04:36:48 +00:00

fix(instances): Refresh ISO list says which pools it could not read

A pool whose refresh failed, one busy with a volume copy for example,
was skipped without a word, so a hand-copied image stayed missing with
no reason given. The other pools are still refreshed; each failure is
shown with libvirt's error.

The API comment no longer says listing the ISO images refreshes pools.
This commit is contained in:
catborise 2026-11-02 16:03:44 +03:00
parent d5d054de71
commit b89672169f
5 changed files with 29 additions and 7 deletions

View file

@ -1715,10 +1715,15 @@ class wvmInstance(wvmConnect):
def refresh_iso_pools(self):
"""Refresh the active pools, so that an image copied to one by hand
is listed by get_iso_media."""
is listed by get_iso_media. A pool that fails does not stop the
others; returns the errors, by pool name."""
failed = {}
for pool in self.wvm.listAllStoragePools(VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE):
with contextlib.suppress(libvirtError): # stopped or removed meanwhile
try:
pool.refresh(0)
except libvirtError as err:
failed[pool.name()] = err
return failed
def get_iso_media(self):
"""The .iso volumes libvirt knows in the active pools; one copied in

View file

@ -91,13 +91,21 @@ class IsoListTestCase(unittest.TestCase):
self.assertEqual(inst.get_iso_media(), ["b.iso"])
def test_refresh_reads_every_active_pool_again(self):
a, b = pool([], refresh_error=True), pool([])
a, b = pool([]), pool([])
inst = self.wvm(a, b)
inst.refresh_iso_pools()
self.assertEqual(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_is_returned_and_the_others_still_run(self):
a, b = pool([], refresh_error=True), pool([])
a.name.return_value = "busy"
failed = self.wvm(a, b).refresh_iso_pools()
self.assertEqual(list(failed), ["busy"])
self.assertIsInstance(failed["busy"], libvirtError)
b.refresh.assert_called_once_with(0)
if __name__ == "__main__":
unittest.main()