mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 04:36:48 +00:00
fix(instances): clones roll back their copies; own error messages stay
Clone: - only shut-off VMs are cloned, as the UI already required: a running guest keeps writing while its disks are copied; the definition comes from the persistent XML; - MAC addresses and disk destinations are checked before anything is allocated; - every volume the clone creates (NVRAM and disks) is tracked; if a later copy or the definition fails, only those are deleted, and any that cannot be deleted are named in the error. Before, a failed clone left its earlier copies behind. libvirtError(msg) reports the thread's last libvirt error instead of msg when there is one, so WebVirtCloud's own errors could show an earlier, unrelated failure. util.OperationError, a libvirtError subclass that keeps its message, replaces those raises in vrtManager, instances and nwfilters; 'except libvirtError' still catches it.
This commit is contained in:
parent
e5fda79f5a
commit
57cf49262a
8 changed files with 282 additions and 139 deletions
|
|
@ -128,5 +128,21 @@ class TestVrtManagerUtil(unittest.TestCase):
|
|||
self.assertIsNone(vol_dev_type("unknown_bus"))
|
||||
|
||||
|
||||
|
||||
class OperationErrorTestCase(unittest.TestCase):
|
||||
def test_keeps_its_own_message_after_a_libvirt_failure(self):
|
||||
import libvirt
|
||||
from vrtManager.util import OperationError
|
||||
|
||||
conn = libvirt.open("test:///default")
|
||||
self.addCleanup(conn.close)
|
||||
with self.assertRaises(libvirt.libvirtError):
|
||||
conn.lookupByName("no-such-domain") # leaves a thread-local last error
|
||||
self.assertNotEqual(str(libvirt.libvirtError("own message")), "own message")
|
||||
error = OperationError("own message")
|
||||
self.assertEqual(str(error), "own message")
|
||||
self.assertIsInstance(error, libvirt.libvirtError)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue