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

feat: tags for VMs and hosts

One list of tag names (lower case letters, digits, dot, dash, underscore;
up to 32) given to VMs and hosts. A superuser sets a VM's tags on its
Options tab and a host's on its form; Tom Select suggests the tags there
are and makes a new one typed. The VM list, the VM page and the hosts list
show them as badges, to everyone who sees the VM or host.

A VM's tags stay with it: an out-of-band move adds them to those on the
new host's record, and a VM that leaves its host keeps them on the Removed
VMs page (a VM with only tags too) and gets them back when it returns.
Setting them is audited and held against the VM's move.
This commit is contained in:
catborise 2026-11-18 19:27:36 +03:00
parent 810abe7475
commit 149530f8df
26 changed files with 1202 additions and 778 deletions

View file

@ -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 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 and tags come back if the same UUID shows up again before the record expires." %}</p>
{% if not tombstones %}
<div class="alert alert-info shadow-sm">
{% bs_icon 'info-circle' %} {% trans "No removed VMs" %}
@ -21,11 +21,12 @@
</div>
<div class="list-group list-group-flush searchable">
{% for tombstone in tombstones %}
<div class="list-group-item py-3" data-search="{{ tombstone.name }} {{ tombstone.uuid }} {{ tombstone.host }} {{ tombstone.owner_names|join:' ' }}">
<div class="list-group-item py-3" data-search="{{ tombstone.name }} {{ tombstone.uuid }} {{ tombstone.host }} {{ tombstone.owner_names|join:' ' }} {{ tombstone.tags|join:' ' }}">
<div class="row g-2 align-items-center">
<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 %}
{% 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>
<div class="col-12 col-md-5 small">

View file

@ -21,6 +21,7 @@ class TombstoneTests(TestCase):
uuid=UUID,
name="ts-vm",
host="ts-host",
tags=["prod"],
owners=[
{"user": self.owner.id, "is_change": True, "is_delete": False, "is_vnc": True},
{"user": 999999, "is_change": False, "is_delete": False, "is_vnc": False},
@ -39,6 +40,7 @@ class TombstoneTests(TestCase):
self.assertContains(response, "ts-vm")
self.assertContains(response, UUID)
self.assertContains(response, "ts-owner")
self.assertContains(response, "prod")
self.assertContains(response, '<span class="fw-semibold">ts-host</span>', html=True)
def test_only_superusers_see_or_remove_them(self):