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:
parent
11b447f681
commit
f4051213fb
15 changed files with 508 additions and 163 deletions
|
|
@ -9,7 +9,7 @@ from rest_framework import viewsets
|
|||
from rest_framework.response import Response
|
||||
from vrtManager.create import wvmCreate
|
||||
|
||||
from .serializers import ComputeSerializer
|
||||
from .serializers import TAG_PARAMETER, ComputeSerializer, with_tag
|
||||
|
||||
|
||||
class ComputeViewSet(viewsets.ModelViewSet):
|
||||
|
|
@ -22,6 +22,14 @@ class ComputeViewSet(viewsets.ModelViewSet):
|
|||
serializer_class = ComputeSerializer
|
||||
permission_classes = [IsSuperUser]
|
||||
|
||||
def get_queryset(self):
|
||||
queryset = super().get_queryset()
|
||||
return with_tag(queryset, self.request) if self.action == "list" else queryset
|
||||
|
||||
@extend_schema(parameters=[TAG_PARAMETER])
|
||||
def list(self, request, *args, **kwargs):
|
||||
return super().list(request, *args, **kwargs)
|
||||
|
||||
# checked and saved under hosts_lock, as on the web (Compute.clean)
|
||||
def create(self, request, *args, **kwargs):
|
||||
with hosts_lock():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue