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

fix(computes): host pages survive a down host and a vTPM secret

- The host graphs and the machine/bus lists connect inside their libvirt
  error handling, so a down host gives empty answers instead of a 500 page
  the polling script drops.
- The Secrets page lists vTPM secrets instead of failing on them, and a
  secret without usage data shows an empty cell instead of "None".
- A TCP/TLS host takes a SASL password longer than 14 characters and a
  login up to the Linux limit of 32.
- The compute edit page says "Edit Compute"; a host without VMs no longer
  closes an extra page element; the memory graph is labelled MiB.
This commit is contained in:
catborise 2026-10-26 14:13:29 +03:00
parent c26e9a49c4
commit 9e02286926
12 changed files with 63 additions and 22 deletions

View file

@ -66,7 +66,7 @@
<tr>
<th scope="row">{{ secret.uuid }}</th>
<td>{{ secret.usageType }}</td>
<td>{{ secret.usage }}</td>
<td>{{ secret.usage|default_if_none:"" }}</td>
<td>
<form action="" method="post" role="form" aria-label="Delete secret form">{% csrf_token %}
<input type="hidden" name="uuid" value="{{ secret.uuid }}"/>

View file

@ -7,12 +7,12 @@ from computes.models import Compute
from django.contrib.auth import get_user_model
from django.test import TestCase
from django.urls import reverse
from libvirt import VIR_SECRET_USAGE_TYPE_CEPH
from libvirt import VIR_SECRET_USAGE_TYPE_CEPH, VIR_SECRET_USAGE_TYPE_VTPM
from lxml import html
class SecretsPageTests(TestCase):
def test_the_page_holds_no_secret_value(self):
def page(self, usage_type):
compute = Compute.objects.create(name="secrets-page", hostname="localhost", login="", password="", type=4)
self.client.force_login(get_user_model().objects.create_superuser("page", "page@example.com", "pw"))
with patch("virtsecrets.views.wvmSecrets") as conn:
@ -20,11 +20,18 @@ class SecretsPageTests(TestCase):
secret = conn.return_value.get_secret.return_value
secret.usageID.return_value = "client.libvirt"
secret.UUIDString.return_value = "0e5b1f0a-8f3e-4c1a-9d2b-5c6d7e8f9a0b"
secret.usageType.return_value = VIR_SECRET_USAGE_TYPE_CEPH
secret.usageType.return_value = usage_type
secret.value.return_value = b"cephx key"
conn.return_value.get_secret_value.return_value = "Y2VwaHgga2V5"
response = self.client.get(reverse("virtsecrets", args=[compute.id]))
self.assertEqual(response.status_code, 200)
return response
def test_a_vtpm_secret_is_listed(self):
self.assertContains(self.page(VIR_SECRET_USAGE_TYPE_VTPM), "vtpm")
def test_the_page_holds_no_secret_value(self):
response = self.page(VIR_SECRET_USAGE_TYPE_CEPH)
self.assertFalse(b"Y2VwaHgga2V5" in response.content, "the secret's value is on the page")
field = html.fromstring(response.content).get_element_by_id("secret_value_0e5b1f0a-8f3e-4c1a-9d2b-5c6d7e8f9a0b")
self.assertIsNone(field.get("value"))

View file

@ -9,6 +9,7 @@ from libvirt import (
VIR_SECRET_USAGE_TYPE_NONE,
VIR_SECRET_USAGE_TYPE_TLS,
VIR_SECRET_USAGE_TYPE_VOLUME,
VIR_SECRET_USAGE_TYPE_VTPM,
libvirtError,
)
from logs.audit import audit
@ -34,6 +35,7 @@ def secrets(request, compute_id):
VIR_SECRET_USAGE_TYPE_CEPH: "ceph",
VIR_SECRET_USAGE_TYPE_ISCSI: "iscsi",
VIR_SECRET_USAGE_TYPE_TLS: "tls",
VIR_SECRET_USAGE_TYPE_VTPM: "vtpm",
}
# the create dialog offers the usage types the form takes
usage_choices = AddSecret.base_fields["usage_type"].choices