1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-01 16:36:06 +00:00

fix(instances): a failed power cycle says the VM stays off; templates have no autostart

Power Cycle forced the VM off and, when the start failed, showed only
libvirt's error: the page now also says the VM was forced off and stays
off, and the audit row says so. A template kept the autostart it had as a
VM, so the host started it although the panel refuses to: marking a
template turns autostart off, and autostart is refused on a template. The
autostart switch is disabled, with the reason, on a template and on a VM
that exists only while it runs (libvirt refuses autostart there).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
catborise 2026-11-11 14:28:35 +03:00
parent 0ce1139c9d
commit 7dd68aaca4
10 changed files with 259 additions and 196 deletions

View file

@ -48,6 +48,15 @@ class VMRowTests(TestCase):
self.proxy.start.assert_called_once_with(libvirt.VIR_DOMAIN_START_FORCE_BOOT)
self.assertEqual(self.rows(), [("VM vm: power on without the saved state", True)])
def test_a_power_cycle_that_does_not_start_again_says_the_vm_stays_off(self):
self.proxy.start.side_effect = libvirtError("Cannot access storage file")
response = self.post("powercycle")
self.proxy.force_shutdown.assert_called_once_with()
self.assertEqual(self.rows(), [("VM vm: power cycle: forced off, the start failed: Cannot access storage file",
False)])
self.assertIn("The VM was forced off but did not start again: it stays off.",
[m.message for m in get_messages(response.wsgi_request)])
def test_a_raised_failure_writes_a_failed_row(self):
self.proxy.start.side_effect = libvirtError("Requested operation is not valid")
self.post("poweron")