[PATCH ha-manager v3 22/40] sim: hardware: factor out static stats' default values

Daniel Kral
2026-03-30T14:43:35Z

From: Dominik Rusovac <d.rusovac@proxmox.com>

Signed-off-by: Dominik Rusovac <d.rusovac@proxmox.com>
Signed-off-by: Daniel Kral <d.kral@proxmox.com>
---
changes v2 -> v3:
- none

src/PVE/HA/Sim/Hardware.pm | 33 +++++++++++++++++++++++++++++----
1 file changed, 29 insertions(+), 4 deletions(-)

diff --git a/src/PVE/HA/Sim/Hardware.pm b/src/PVE/HA/Sim/Hardware.pm
index cfcd7ab1..34d67754 100644
--- a/src/PVE/HA/Sim/Hardware.pm
+++ b/src/PVE/HA/Sim/Hardware.pm
@@ -21,6 +21,11 @@ use PVE::HA::Groups;

my $watchdog_timeout = 60;

+my $default_service_maxcpu = 4.0;
+my $default_service_maxmem = 4096 * 1024**2;
+my $default_node_maxcpu = 24.0;
+my $default_node_maxmem = 131072 * 1024**2;
+
# Status directory layout
#
# configuration
@@ -488,9 +493,24 @@ sub new {
|| die "Copy failed: $!\n";
} else {
my $cstatus = {
- node1 => { power => 'off', network => 'off', maxcpu => 24.0, maxmem => 131072 },
- node2 => { power => 'off', network => 'off', maxcpu => 24.0, maxmem => 131072 },
- node3 => { power => 'off', network => 'off', maxcpu => 24.0, maxmem => 131072 },
+ node1 => {
+ power => 'off',
+ network => 'off',
+ maxcpu => $default_node_maxcpu,
+ maxmem => $default_node_maxmem,
+ },
+ node2 => {
+ power => 'off',
+ network => 'off',
+ maxcpu => $default_node_maxcpu,
+ maxmem => $default_node_maxmem,
+ },
+ node3 => {
+ power => 'off',
+ network => 'off',
+ maxcpu => $default_node_maxcpu,
+ maxmem => $default_node_maxmem,
+ },
};
$self->write_hardware_status_nolock($cstatus);
}
@@ -507,7 +527,12 @@ sub new {
copy("$testdir/static_service_stats", "$statusdir/static_service_stats");
} else {
my $services = $self->read_service_config();
- my $stats = { map { $_ => { maxcpu => 4.0, maxmem => 4096 } } keys %$services };
+ my $stats = {
+ map {
+ $_ => { maxcpu => $default_service_maxcpu, maxmem => $default_service_maxmem }
+ }
+ keys %$services
+ };
$self->write_static_service_stats($stats);
}

--
2.47.3