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

feat: a Tags page and tags in the API

Administration gets a Tags page: each tag with how many VMs and hosts
have it, renamed (on the VMs, hosts and removed VMs that keep it) or
deleted (taken off all of them). Both are logged.

The API gives a VM's and a host's tags by name, read only, and its VM
and host lists take ?tag= for those with a tag.
This commit is contained in:
catborise 2026-11-18 20:50:59 +03:00
parent 11b447f681
commit f4051213fb
15 changed files with 508 additions and 163 deletions

View file

@ -1,3 +1,4 @@
from computes.api.serializers import TAGS
from computes.models import Compute
from django.conf import settings
from instances.models import Flavor, Instance
@ -7,9 +8,11 @@ from rest_framework import serializers
class InstanceSerializer(serializers.ModelSerializer):
tags = serializers.SlugRelatedField(**TAGS)
class Meta:
model = Instance
fields = ["id", "compute", "name", "uuid", "is_template", "created", "drbd"]
fields = ["id", "compute", "name", "uuid", "is_template", "created", "drbd", "tags"]
# what a VM's device dicts tell of the host: its files and pools
@ -18,6 +21,7 @@ HOST_KEYS = {"image", "storage", "path", "backing_file", "loader"}
class InstanceDetailsSerializer(serializers.ModelSerializer):
networks = serializers.SerializerMethodField()
tags = serializers.SlugRelatedField(**TAGS)
def get_networks(self, instance) -> list[dict]:
"""Each NIC with its addresses (None: none known), which the VM page
@ -58,6 +62,7 @@ class InstanceDetailsSerializer(serializers.ModelSerializer):
"status",
"uuid",
"name",
"tags",
"title",
"description",
"is_template",