mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-02 17:06:09 +00:00
fix(computes): a VM that returns gets its protection, schedules and backups back
A VM that vanished from its compute, or whose compute was deleted and added again, came back with its owners and tags only: it was no longer protected, its schedules no longer backed it up, and its backups stayed unlinked, so its Backups tab no longer listed them and retention left them for good. The Removed VMs record now keeps its protection, its schedules and its own backups (not those of a copy under the same UUID), and gives them back. Turning protection on or off waits for the ownership step, so a VM dropped from its host's list meanwhile is not told protected.
This commit is contained in:
parent
5c7687c60d
commit
dc5b1dbb2a
14 changed files with 251 additions and 138 deletions
|
|
@ -8,7 +8,7 @@
|
|||
{% block page_heading %}{% trans "Removed VMs" %}{% endblock page_heading %}
|
||||
|
||||
{% block content %}
|
||||
<p class="text-body-secondary">{% trans "VMs that vanished from their compute. Their owners and tags come back if the same UUID shows up again before the record expires." %}</p>
|
||||
<p class="text-body-secondary">{% trans "VMs that vanished from their compute. Their owners, tags, protection and schedules come back if the same UUID shows up again before the record expires; their backups come back with them." %}</p>
|
||||
{% if not tombstones %}
|
||||
<div class="alert alert-info shadow-sm">
|
||||
{% bs_icon 'info-circle' %} {% trans "No removed VMs" %}
|
||||
|
|
@ -26,6 +26,7 @@
|
|||
<div class="col-12 col-md-4">
|
||||
<span class="fw-semibold text-break">{{ tombstone.name }}</span>
|
||||
{% if tombstone.is_template %}<span class="badge text-bg-light border">{% trans "Template" %}</span>{% endif %}
|
||||
{% if tombstone.protected %}<span class="badge text-bg-light border">{% trans "Protected" %}</span>{% endif %}
|
||||
{% include 'common/tag_badges.html' with tags=tombstone.tags %}
|
||||
<div class="font-monospace small text-body-secondary text-break mt-1">{{ tombstone.uuid }}</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class TombstoneTests(TestCase):
|
|||
def test_a_get_only_asks_for_confirmation(self):
|
||||
response = self.client.get(reverse("admin:tombstone_delete", args=[self.tombstone.pk]))
|
||||
self.assertContains(response, "ts-vm")
|
||||
self.assertContains(response, "Its owners and tags no longer come back if its UUID shows up again.")
|
||||
self.assertContains(response, "Its owners, tags, protection and schedules no longer come back if its UUID shows up again, nor are its backups linked to it again.")
|
||||
self.assertTrue(InstanceTombstone.objects.exists())
|
||||
|
||||
def test_a_post_removes_it(self):
|
||||
|
|
|
|||
|
|
@ -462,7 +462,7 @@ def tombstone_delete(request, pk):
|
|||
request,
|
||||
"common/confirm_delete.html",
|
||||
{"object": tombstone,
|
||||
"consequence": _("Its owners and tags no longer come back if its UUID shows up again.")},
|
||||
"consequence": _("Its owners, tags, protection and schedules no longer come back if its UUID shows up again, nor are its backups linked to it again.")},
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -485,7 +485,7 @@ def _retag_removed_vms(old, new):
|
|||
tombstone.tags = [new if name == old else name for name in tombstone.tags]
|
||||
else:
|
||||
tombstone.tags = [name for name in tombstone.tags if name != old]
|
||||
if tombstone.tags or tombstone.owners or tombstone.is_template:
|
||||
if tombstone.keeps_anything():
|
||||
tombstone.save(update_fields=["tags"])
|
||||
else: # kept only for the tag (computes.utils._bury)
|
||||
tombstone.delete()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue