1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 17:36:05 +00:00

feat(computes): the Computes list on Bootstrap's cards, badges, bars and menus

- Totals above the list: hosts connected of all, VMs running of all,
  vCPUs given on the CPUs, memory given of the memory of the hosts the
  panel reads, as cards; the connected count is red while a host is
  not.
- A host's name links its overview; its state is a Connected or Not
  connected badge (the dot goes), beside a badge of how the panel
  reaches it (TCP, SSH, TLS, Socket); its address in monospace.
- A VMs column: the host's VMs, linked to its Instances, and how many
  run.
- The vCPUs have a bar like the memory's: running VMs' and shut-off
  VMs' vCPUs against the CPUs, amber over 2:1 and red over 4:1 as the
  ratio is; the overview's vCPU card shares it.
- The three coloured buttons of each row are one menu: Overview, Edit
  connection and Remove from panel (its popper fixed, as the table's
  scrolling box would cut it off).
- The four green add buttons are one "Add host" menu that says what
  each kind of connection is.
- The table is table-hover; a host the panel cannot reach has a
  table-warning row.
This commit is contained in:
catborise 2026-10-27 21:41:06 +03:00
parent 0207514b52
commit 025bb16557
10 changed files with 207 additions and 88 deletions

View file

@ -50,14 +50,20 @@ class ComputesPageTests(TestCase):
page = html.fromstring(self.client.get(reverse("computes")).content)
headers = [" ".join(th.text_content().split()) for th in page.xpath("//thead//th")]
# no pools: measuring their space scans each pool of each host (views.host_pools)
self.assertEqual(headers, ["Host", "vCPUs", "Memory", "Actions"])
self.assertEqual(headers, ["Host", "VMs", "vCPUs", "Memory", "Actions"])
one, two = page.xpath("//tbody/tr")
cells = [" ".join(td.text_content().split()) for td in one.xpath("td")]
self.assertIn("host-one", cells[0])
self.assertIn("2.5:1", cells[1])
self.assertIn("40 vCPUs on 16 CPUs 24 running", cells[1])
self.assertIn("75 % 48.0 GB / 64.0 GB", cells[2])
self.assertIn("32.0 GB running", cells[2])
self.assertIn("host-one Connected TCP 192.0.2.1", cells[0])
self.assertEqual(cells[1], "6 3 running")
self.assertIn("2.5:1", cells[2])
self.assertIn("40 vCPUs on 16 CPUs", cells[2])
self.assertIn("24 running", cells[2])
self.assertIn("75 % 48.0 GB / 64.0 GB", cells[3])
self.assertIn("32.0 GB running", cells[3])
# the totals of the hosts read: host-two's capacity could not be
totals = [" ".join(card.text_content().split()) for card in page.xpath("//div[@class='card-body']")]
self.assertEqual(totals, ["Hosts 2 / 2 connected", "VMs 3 / 6 running", "vCPUs given 40 on 16 CPUs",
"Memory given 48.0 GB of 64.0 GB"])
# host-two could not be read: one cell says so
self.assertIn("capacity could not be read", " ".join(two.text_content().split()))
@ -72,7 +78,7 @@ class SingularTests(TestCase):
with patch.object(Compute, "capacity", new=given), patch.object(Compute, "status", new=True):
page = html.fromstring(self.client.get(reverse("computes")).content)
line = self.client.get(reverse("compute_capacity", args=[c.id])).content.decode()
(cell,) = page.xpath("//tbody/tr/td[2]")
(cell,) = page.xpath("//tbody/tr/td[3]")
self.assertIn("1 vCPU on 1 CPU", " ".join(cell.text_content().split()))
self.assertEqual(" ".join(line.split()), "Given to VMs: 1 vCPU (1.0:1), 1.0 GB memory.")

View file

@ -117,4 +117,5 @@ class OverviewTestCase(TestCase):
def test_the_list_links_the_overview_of_a_host_it_cannot_reach(self):
with patch.object(Compute, "status", new_callable=PropertyMock, return_value=False):
page = html.fromstring(self.client.get(reverse("computes")).content)
self.assertTrue(page.xpath(f"//a[@title='Overview'][@href='{self.url}']"))
# its name and its menu's Overview
self.assertEqual(len(page.xpath(f"//tbody//a[@href='{self.url}']")), 2)

View file

@ -22,5 +22,5 @@ class OverviewStatusTests(TestCase):
Compute, "connection_error", new_callable=PropertyMock, return_value=ERROR
):
response = self.client.get(reverse("computes"))
self.assertContains(response, "Not Connected")
self.assertContains(response, "Not connected")
self.assertContains(response, ERROR)