mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
feat(instances): a protected VM is not deleted nor restored over
A superuser turns a VM's protection on or off on its Settings tab, not while a job holds the VM (a deletion or a restore over it that runs would not stop). While it is on, its deletion (page, API, a queued job at its start) and a restore of a backup over it are refused; the Destroy tab, the destroy page and the restore page say so. A VM moved outside the panel keeps it. The API shows the flag read-only.
This commit is contained in:
parent
57e90e0d27
commit
adb4231db7
21 changed files with 706 additions and 491 deletions
|
|
@ -37,7 +37,7 @@ class OwnershipTestCase(TestCase):
|
|||
compute.proxy.wvm.listAllDomains.return_value = [Domain(n, u) for n, u in domains]
|
||||
|
||||
def owned_vm(self, compute):
|
||||
vm = Instance.objects.create(compute=compute, name="vm", uuid=UUID, is_template=True)
|
||||
vm = Instance.objects.create(compute=compute, name="vm", uuid=UUID, is_template=True, protected=True)
|
||||
UserInstance.objects.create(instance=vm, user=self.owner, is_change=True, is_vnc=True)
|
||||
return vm
|
||||
|
||||
|
|
@ -77,6 +77,7 @@ class OwnershipTestCase(TestCase):
|
|||
refresh_instance_database(self.host_a) # gone from A: it moved to B
|
||||
|
||||
self.assertEqual(self.ownership(self.host_b), (True, [(self.owner, True, False, True)]))
|
||||
self.assertTrue(Instance.objects.get(compute=self.host_b).protected)
|
||||
self.assertFalse(Instance.objects.filter(compute=self.host_a).exists())
|
||||
self.assertEqual(self.rows(), [("-", "host-a", f"VM vm ({UUID}): owners moved to host-b")])
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue