mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-08 19:26:48 +00:00
- A Devices section of each host lists its PCI devices by IOMMU group and its USB devices: what each is (vendor, product, IDs, class, driver), what the host itself has on it (its network interfaces, disks and graphics card, anywhere below it) and the VMs whose definitions name it. - A VM names a PCI device by its address, a USB device by its address or by its model only; a VM that names a model only is shown on every device of that model, which one it takes is known only when it starts. - A host without IOMMU groups says that no PCI device can be given to a VM and how to turn the IOMMU on. - One listing of the host's node devices, one XML read each (a device gone meanwhile is left out), and the VMs' definitions read once; nothing is shown when they cannot be read, as a device would look free. - Read only: giving devices to VMs comes in the next layers.
25 lines
1 KiB
Python
25 lines
1 KiB
Python
"""The host pages' shared section links."""
|
|
|
|
from django.template.loader import render_to_string
|
|
from django.test import TestCase
|
|
from lxml import html
|
|
|
|
from computes.models import Compute
|
|
|
|
|
|
class HostNavTestCase(TestCase):
|
|
def setUp(self):
|
|
self.compute = Compute.objects.create(name="c", hostname="192.0.2.1", login="u", password="p", type=1)
|
|
|
|
def items(self, **context):
|
|
nav = html.fromstring(render_to_string("computes/host_nav.html", {"compute": self.compute, **context}))
|
|
return {item.text_content().strip(): (item.tag, item.get("aria-current")) for item in nav.xpath("//li/*")}
|
|
|
|
def test_the_section_s_own_page_is_the_current_page(self):
|
|
items = self.items(section="storages")
|
|
self.assertEqual(len(items), 8)
|
|
self.assertEqual(items["Storages"], ("span", "page"))
|
|
self.assertEqual(items["Overview"], ("a", None))
|
|
|
|
def test_an_item_of_a_section_links_the_section_as_where_it_is(self):
|
|
self.assertEqual(self.items(section="networks", detail=True)["Networks"], ("a", "true"))
|