mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 12:46:49 +00:00
chore: remove code nothing uses
Each was checked with git grep across every tracked file (templates, JS, shell, unit files and the extensionless console daemons) and for dynamic use (URL names, template names, registries): - vrtManager: host_is_up, is_kvm_supported, get_emulators, get_file_extensions, both get_network_forward, get_snapshots, get_storages_images, get_os_type, get_host_arch, the get_pretty_* trio and, in util, is_kvm_available, randomMAC, get_max_vcpus, compareMAC, pretty_mem, pretty_bytes and validate_uuid; with them the port constants only host_is_up read. Some were reached only by their tests, which go too. - The flavor edit page: nothing linked to it; flavors are created and deleted on the Flavors page and edited through the API. - computes.validate_name, UserForm.identity_has_errors, the has_perm template tag, the ALLOW_EMPTY_PASSWORD setting nothing reads, hidePleaseWaitDialog, default_app_config (ignored since Django 4.1) and the Python < 3.6 lines of secret_generator.py.
This commit is contained in:
parent
02412b7ea5
commit
764cbb3c43
26 changed files with 307 additions and 690 deletions
|
|
@ -1 +0,0 @@
|
|||
default_app_config = 'instances.apps.InstancesConfig'
|
||||
|
|
@ -54,8 +54,6 @@ class FlavorRowTests(TestCase):
|
|||
data = {"label": "tiny-a", "memory": 512, "vcpu": 1, "disk": 10}
|
||||
self.client.post(reverse("instances:flavor_create"), data)
|
||||
flavor = Flavor.objects.get(label="tiny-a")
|
||||
self.client.post(reverse("instances:flavor_update", args=[flavor.pk]), {**data, "vcpu": 2})
|
||||
self.client.post(reverse("instances:flavor_update", args=[flavor.pk]), {**data, "vcpu": 2}) # no change
|
||||
self.client.post(reverse("instances:flavor_delete", args=[flavor.pk]))
|
||||
self.assertFalse(Flavor.objects.filter(label="tiny-a").exists())
|
||||
|
||||
|
|
@ -71,6 +69,6 @@ class FlavorRowTests(TestCase):
|
|||
self.assertFalse(Flavor.objects.filter(label="huge-a").exists())
|
||||
|
||||
self.assertEqual([m for m, _ in rows()], [
|
||||
"Flavor tiny-a: add", "Flavor tiny-a: change vcpu", "Flavor tiny-a: delete",
|
||||
"Flavor tiny-a: add", "Flavor tiny-a: delete",
|
||||
"Flavor huge-a: add", "Flavor huge-a: change vcpu", "Flavor huge-a: change memory", "Flavor huge-a: delete",
|
||||
])
|
||||
|
|
|
|||
|
|
@ -1080,21 +1080,6 @@ class InstancesTestCase(TestCase):
|
|||
|
||||
id = Flavor.objects.last().id
|
||||
|
||||
response = self.client.get(reverse("instances:flavor_update", args=[id]))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
response = self.client.post(
|
||||
reverse("instances:flavor_update", args=[id]),
|
||||
{
|
||||
"label": "test_flavor_",
|
||||
"memory": 256,
|
||||
"vcpu": 1,
|
||||
"disk": 10,
|
||||
},
|
||||
HTTP_REFERER=reverse("index"),
|
||||
)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
|
||||
response = self.client.get(reverse("instances:flavor_delete", args=[id]))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ urlpatterns = [
|
|||
path("find_address/", views.find_address, name="find_address"),
|
||||
path("report.xlsx", views.vm_report, name="vm_report"),
|
||||
path("flavor/create/", views.flavor_create, name="flavor_create"),
|
||||
path("flavor/<int:pk>/update/", views.flavor_update, name="flavor_update"),
|
||||
path("flavor/<int:pk>/delete/", views.flavor_delete, name="flavor_delete"),
|
||||
path("<int:pk>/", views.instance, name="instance"),
|
||||
path("<int:pk>/poweron/", views.poweron, name="poweron"),
|
||||
|
|
|
|||
|
|
@ -46,8 +46,7 @@ from libvirt import (VIR_DOMAIN_PAUSED,
|
|||
VIR_ERR_NO_DOMAIN,
|
||||
VIR_ERR_NO_SUPPORT,
|
||||
libvirtError)
|
||||
from logs.audit import audit, audit_vm, changed_fields, failed_vm
|
||||
from logs.audit import snapshot as audit_snapshot
|
||||
from logs.audit import audit, audit_vm, failed_vm
|
||||
from operations import claims, jobs
|
||||
from operations.utils import HOST_BUSY, busy_message, summary
|
||||
from webvirtcloud.middleware import error_text, same_origin_referer
|
||||
|
|
@ -2643,27 +2642,6 @@ def flavor_create(request):
|
|||
)
|
||||
|
||||
|
||||
@superuser_only
|
||||
def flavor_update(request, pk):
|
||||
flavor = get_object_or_404(Flavor, pk=pk)
|
||||
subject, before = f"Flavor {flavor.label}", audit_snapshot(flavor)
|
||||
form = FlavorForm(request.POST or None, instance=flavor)
|
||||
if form.is_valid():
|
||||
with audit(request, None, subject, "change") as entry:
|
||||
form.save()
|
||||
fields = changed_fields(before, audit_snapshot(flavor))
|
||||
entry.action = "change " + ", ".join(fields)
|
||||
entry.skip = not fields
|
||||
messages.success(request, _("Flavor Updated"))
|
||||
return get_safe_redirect(request, default=reverse("instances:index"))
|
||||
|
||||
return render(
|
||||
request,
|
||||
"common/form.html",
|
||||
{"form": form, "title": _("Update Flavor")},
|
||||
)
|
||||
|
||||
|
||||
@superuser_only
|
||||
def flavor_delete(request, pk):
|
||||
flavor = get_object_or_404(Flavor, pk=pk)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue