1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 17:36:05 +00:00

fix(instances): a VM with a saved state says so and can start without it

A VM with a managed save image showed as plain Off; Power On restored the
saved memory and the panel had no way to boot it fresh or drop the saved
state. The power tab now says the VM has a saved state and offers Start
Without Saved State (confirmed), which boots it with
VIR_DOMAIN_START_FORCE_BOOT and so discards the image. Owners get it as
they get Power On; the audit row names it.
This commit is contained in:
catborise 2026-11-11 14:27:00 +03:00
parent 1957a5a85a
commit dba2c2b1c2
11 changed files with 308 additions and 225 deletions

View file

@ -4,6 +4,8 @@ web forms take."""
from unittest.mock import patch
import libvirt
from accounts.models import UserInstance
from computes.models import Compute
from django.contrib.auth import get_user_model
@ -22,6 +24,15 @@ class ApiParityTests(TestCase):
UserInstance.objects.create(user=self.user, instance=self.vm)
self.url = f"/api/v1/computes/{self.compute.id}/instances/{self.vm.id}/"
def test_a_json_body_starts_a_vm_without_its_saved_state(self):
Instance.objects.filter(pk=self.vm.pk).update(is_template=False)
self.client.force_login(self.user)
with patch("instances.models.wvmInstance") as wvm:
wvm.return_value.get_status.return_value = 5
response = self.client.post(self.url + "poweron/", {"fresh": True}, content_type="application/json")
self.assertEqual(response.status_code, 200)
wvm.return_value.start.assert_called_once_with(libvirt.VIR_DOMAIN_START_FORCE_BOOT)
def test_a_template_is_not_started(self):
self.client.force_login(self.user)
with patch("instances.models.wvmInstance") as wvm: