mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 12:46:49 +00:00
perf(computes): a host's CPU count and memory come from its cached info
cpu_count and ram_size each called get_node_info(), which also reads the hostname, the sysinfo XML and the URI, for one value. Both now take it from host_info, the getInfo() read the proxy keeps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
parent
490b7efe3f
commit
a1f90ec98c
2 changed files with 9 additions and 3 deletions
|
|
@ -90,11 +90,11 @@ class Compute(Model):
|
|||
|
||||
@cached_property
|
||||
def cpu_count(self):
|
||||
return self.proxy.get_node_info()[3]
|
||||
|
||||
return self.proxy.host_info[2]
|
||||
|
||||
@cached_property
|
||||
def ram_size(self):
|
||||
return self.proxy.get_node_info()[2]
|
||||
return self.proxy.host_info[1] * 1048576 # MiB
|
||||
|
||||
@cached_property
|
||||
def ram_usage(self):
|
||||
|
|
|
|||
|
|
@ -36,6 +36,12 @@ class CapacityTests(TestCase):
|
|||
self.assertIsNone(self.compute.capacity)
|
||||
details.assert_not_called()
|
||||
|
||||
@patch("computes.models.wvmHostDetails")
|
||||
def test_cpus_and_memory_come_from_the_host_info(self, details):
|
||||
details.return_value.host_info = ["x86_64", 32768, 8, 2400]
|
||||
self.assertEqual((self.compute.cpu_count, self.compute.ram_size), (8, 32 * GIB))
|
||||
details.return_value.get_node_info.assert_not_called() # no hostname, sysinfo or URI read
|
||||
|
||||
|
||||
class ComputesPageTests(TestCase):
|
||||
def test_the_list_shows_what_each_compute_has_given(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue