1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-10 12:16:49 +00:00

feat(virtsecrets): the secrets page on Bootstrap's cards, tables and dialogs

- One searchable card: each secret's type, usage and UUID, whether it is
  kept on disk or in memory and private, and the VMs and pools that use it,
  linked. A row menu sets its value or deletes it; Delete is disabled while
  the secret is in use, and its confirmation says what is not checked.
- One Set value dialog for every secret; its label and help follow the
  type (Ceph key, CHAP password, passphrase), and it says a new passphrase
  does not encrypt anew what the old one encrypted.
- New secret dialog: the usage's and value's labels and help follow the
  type; the value is optional; Private and Ephemeral are switches with help.
This commit is contained in:
catborise 2026-10-29 09:38:08 +03:00
parent a95ec40f69
commit 2a773f6ec0
5 changed files with 249 additions and 138 deletions

View file

@ -3,6 +3,7 @@ from computes.models import Compute
from django.contrib import messages
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
from instances.models import Instance
from libvirt import libvirtError
from logs.audit import audit
from vrtManager.virtsecrets import wvmSecrets
@ -44,8 +45,13 @@ def secrets(request, compute_id):
# shown only with their users: a list without them would offer to delete secrets in use
secrets = conn.get_secrets_info()
users = conn.get_users(secrets)
vm_ids = dict(Instance.objects.filter(compute=compute).values_list("name", "id"))
labels = dict(AddSecret.base_fields["usage_type"].choices)
for secret in secrets:
secret.update(users.get(secret["uuid"], {"vms": [], "pools": []}))
used = users.get(secret["uuid"], {"vms": [], "pools": []})
secret["vms"] = [{"name": name, "id": vm_ids.get(name)} for name in used["vms"]]
secret["pools"] = used["pools"]
secret["type_label"] = labels.get(secret["usage_type"], secret["usage_type"])
secrets_all = secrets
except libvirtError as err: # OperationError too: a secret in use, a Ceph key not base64
messages.error(request, err)