]> git.proxmox.com Git - pve-ha-manager.git/commitdiff
resources: pve: avoid relying on internal configuration details
authorFiona Ebner <f.ebner@proxmox.com>
Tue, 28 Feb 2023 10:54:10 +0000 (11:54 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 9 Jun 2023 05:28:29 +0000 (07:28 +0200)
Instead, use the new get_derived_property() method to get the same
information in a way that is robust regarding changes in the
configuration structure.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
src/PVE/HA/Resources/PVECT.pm
src/PVE/HA/Resources/PVEVM.pm

index e77d98ccb0227c523076b530cd8373558576e255..6e1469215975e038cb0833e006fae6211dd740bc 100644 (file)
@@ -158,8 +158,8 @@ sub get_static_stats {
     my $conf = PVE::LXC::Config->load_config($id, $service_node);
 
     return {
-       maxcpu => $conf->{cpulimit} || $conf->{cores} || 0,
-       maxmem => ($conf->{memory} || 512) * 1024 * 1024,
+       maxcpu => PVE::LXC::Config->get_derived_property($conf, 'max-cpu'),
+       maxmem => PVE::LXC::Config->get_derived_property($conf, 'max-memory'),
     };
 }
 
index f405d8616c322502d65b64d0afa4a6900e4c9363..1543a2dd29023e32bac40843660646636aa4619f 100644 (file)
@@ -179,13 +179,10 @@ sub get_static_stats {
     my ($class, $haenv, $id, $service_node) = @_;
 
     my $conf = PVE::QemuConfig->load_config($id, $service_node);
-    my $defaults = PVE::QemuServer::load_defaults();
-
-    my $cpus = ($conf->{sockets} || $defaults->{sockets}) * ($conf->{cores} || $defaults->{cores});
 
     return {
-       maxcpu => $conf->{vcpus} || $cpus,
-       maxmem => ($conf->{memory} || $defaults->{memory}) * 1024 * 1024,
+       maxcpu => PVE::QemuConfig->get_derived_property($conf, 'max-cpu'),
+       maxmem => PVE::QemuConfig->get_derived_property($conf, 'max-memory'),
     };
 }