mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 12:46:49 +00:00
refactor(computes): drop the unused domain capabilities endpoint
No page or script called it, and it answered with the disk device types for both videos and buses. The create view keeps reading the domain capabilities through wvmConnect. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b45f673da7
commit
aa720e09e8
4 changed files with 1 additions and 38 deletions
|
|
@ -186,15 +186,6 @@ class ComputesTestCase(TestCase):
|
||||||
response = self.client.get(reverse("buses", args=[self.compute.id, "x86_64", "q35", "disk"]))
|
response = self.client.get(reverse("buses", args=[self.compute.id, "x86_64", "q35", "disk"]))
|
||||||
self.assertEqual(json.loads(response.content), {"bus": ["sata", "scsi", "virtio"]})
|
self.assertEqual(json.loads(response.content), {"bus": ["sata", "scsi", "virtio"]})
|
||||||
|
|
||||||
def test_dom_capabilities(self):
|
|
||||||
self._require_live_compute()
|
|
||||||
response = self.client.get(
|
|
||||||
reverse(
|
|
||||||
"domcaps", kwargs={"compute_id": self.compute.id, "arch": "x86_64", "machine": "pc"}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
self.assertEqual(response.status_code, 200)
|
|
||||||
|
|
||||||
|
|
||||||
class ComputeConcurrencyTestCase(TransactionTestCase):
|
class ComputeConcurrencyTestCase(TransactionTestCase):
|
||||||
def test_concurrent_refresh_instance_database(self):
|
def test_concurrent_refresh_instance_database(self):
|
||||||
|
|
|
||||||
|
|
@ -85,11 +85,6 @@ urlpatterns = [
|
||||||
views.get_compute_disk_buses,
|
views.get_compute_disk_buses,
|
||||||
name="buses",
|
name="buses",
|
||||||
),
|
),
|
||||||
path(
|
|
||||||
"archs/<str:arch>/machines/<str:machine>/capabilities",
|
|
||||||
views.get_dom_capabilities,
|
|
||||||
name="domcaps",
|
|
||||||
),
|
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -167,18 +167,6 @@ def get_compute_machine_types(request, compute_id, arch):
|
||||||
return HttpResponse(comp_mgr.get_machine_types(arch), content_type="application/json")
|
return HttpResponse(comp_mgr.get_machine_types(arch), content_type="application/json")
|
||||||
|
|
||||||
|
|
||||||
def get_dom_capabilities(request, compute_id, arch, machine):
|
|
||||||
"""
|
|
||||||
:param request:
|
|
||||||
:param compute_id:
|
|
||||||
:param arch:
|
|
||||||
:param machine:
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
comp_mgr = ComputeManager(compute_id)
|
|
||||||
return HttpResponse(comp_mgr.get_dom_capabilities(arch, machine), content_type="application/json")
|
|
||||||
|
|
||||||
|
|
||||||
class ComputeManager:
|
class ComputeManager:
|
||||||
def __init__(self, compute_id):
|
def __init__(self, compute_id):
|
||||||
self.compute = get_object_or_404(Compute, pk=compute_id)
|
self.compute = get_object_or_404(Compute, pk=compute_id)
|
||||||
|
|
@ -189,16 +177,6 @@ class ComputeManager:
|
||||||
self.compute.type,
|
self.compute.type,
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_dom_capabilities(self, arch, machine):
|
|
||||||
data = dict()
|
|
||||||
try:
|
|
||||||
data["videos"] = self.conn.get_disk_device_types(arch, machine)
|
|
||||||
data["bus"] = self.conn.get_disk_device_types(arch, machine)
|
|
||||||
except libvirtError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
return json.dumps(data)
|
|
||||||
|
|
||||||
def get_machine_types(self, arch):
|
def get_machine_types(self, arch):
|
||||||
data = dict()
|
data = dict()
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
|
|
@ -87,10 +87,9 @@ class JsonEndpointContentTypeTestCase(TestCase):
|
||||||
reverse("compute_graph", args=[self.compute.id]),
|
reverse("compute_graph", args=[self.compute.id]),
|
||||||
reverse("machines", args=[self.compute.id, "x86_64"]),
|
reverse("machines", args=[self.compute.id, "x86_64"]),
|
||||||
reverse("buses", args=[self.compute.id, "x86_64", "q35", "disk"]),
|
reverse("buses", args=[self.compute.id, "x86_64", "q35", "disk"]),
|
||||||
reverse("domcaps", args=[self.compute.id, "x86_64", "q35"]),
|
|
||||||
]
|
]
|
||||||
with patch("computes.views.ComputeManager") as mock_mgr:
|
with patch("computes.views.ComputeManager") as mock_mgr:
|
||||||
for method in ("compute_graph", "get_machine_types", "get_disk_buses", "get_dom_capabilities"):
|
for method in ("compute_graph", "get_machine_types", "get_disk_buses"):
|
||||||
getattr(mock_mgr.return_value, method).return_value = "{}"
|
getattr(mock_mgr.return_value, method).return_value = "{}"
|
||||||
for url in urls:
|
for url in urls:
|
||||||
with self.subTest(url=url):
|
with self.subTest(url=url):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue