mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
fix(vmbackups): seventh audit: files of a VM named after a backup, restore-over page
- A VM may be named "<another backup's prefix>-x": its backups' files then begin with that prefix too, and deleting the other backup removed them. Backup.owns() takes a file only when no other backup UUID follows the prefix; deletion and the storage pages' refusal use it. - The restore-over page failed with a server error when the VM's pool could not be read while naming the copies; it now says why.
This commit is contained in:
parent
5b05e76ebc
commit
348628f13d
6 changed files with 36 additions and 3 deletions
|
|
@ -63,6 +63,21 @@ class DeleteBackupTests(TransactionTestCase):
|
|||
self.assertEqual(self.removed, [[f"{prefix}-manifest.json"], [f"{prefix}-vda.qcow2", f"{prefix}-domain.xml"]])
|
||||
self.assertFalse(Backup.objects.exists())
|
||||
|
||||
def test_a_vm_named_after_this_backup_keeps_its_backups_files(self):
|
||||
# a VM may be named "<this backup's prefix>-x": its backups' files begin with this prefix too
|
||||
other = f"{self.backup.prefix}-x-00000000-0000-4000-8000-00000000000a"
|
||||
self.pool.listVolumes.return_value = [*self.pool.listVolumes.return_value, f"{other}-vda.qcow2",
|
||||
f"{other}-manifest.json"]
|
||||
self.run_job(self.submit())
|
||||
self.assertNotIn(f"{other}-vda.qcow2", sum(self.removed, []))
|
||||
|
||||
def test_its_volumes_are_refused_but_not_those_of_a_vm_named_after_it(self):
|
||||
from vmbackups.utils import refuse_backup_volume
|
||||
|
||||
with self.assertRaises(OperationError):
|
||||
refuse_backup_volume(self.compute, "b1", f"{self.backup.prefix}-vda.qcow2")
|
||||
refuse_backup_volume(self.compute, "b1", f"{self.backup.prefix}-x-00000000-0000-4000-8000-00000000000a-vda.qcow2")
|
||||
|
||||
def test_the_pool_is_refreshed_before_the_manifest_is_looked_up(self):
|
||||
# another compute made the backup: this one's pool lists its files only after a refresh
|
||||
self.pool.refresh.side_effect = lambda flags: self.removed.append("refresh")
|
||||
|
|
|
|||
|
|
@ -350,6 +350,15 @@ class RestoreOverTests(TransactionTestCase):
|
|||
self.assertContains(response, "Shut the VM down")
|
||||
self.assertNotContains(response, "key-") # no form
|
||||
|
||||
def test_the_page_says_why_when_the_pool_cannot_be_read(self):
|
||||
from django.urls import reverse
|
||||
|
||||
self.dest.refresh.side_effect = error(libvirt.VIR_ERR_INTERNAL_ERROR)
|
||||
self.client.force_login(self.admin)
|
||||
response = self.client.get(reverse("vmbackups:restore_over", args=[self.backup.uuid]))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertNotContains(response, "key-") # no form
|
||||
|
||||
def test_only_superusers_and_a_backup_with_its_vm(self):
|
||||
from django.urls import reverse
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue