]> git.proxmox.com Git - pve-container.git/commitdiff
config: implement method to calculate derived properties from a config
authorFiona Ebner <f.ebner@proxmox.com>
Tue, 28 Feb 2023 10:54:08 +0000 (11:54 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 9 Jun 2023 05:50:04 +0000 (07:50 +0200)
See the corresponding commit in guest-common for more information.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
src/PVE/LXC/Config.pm

index ac9db945b78a45e96f2a6e40c61023aa70fb8778..2dd57e2b630a318514872183d6f3a16da0163b66 100644 (file)
@@ -1754,4 +1754,16 @@ sub get_backup_volumes {
     return $return_volumes;
 }
 
+sub get_derived_property {
+    my ($class, $conf, $name) = @_;
+
+    if ($name eq 'max-cpu') {
+       return $conf->{cpulimit} || $conf->{cores} || 0;
+    } elsif ($name eq 'max-memory') {
+       return ($conf->{memory} || 512) * 1024 * 1024;
+    } else {
+       die "unknown derived property - $name\n";
+    }
+}
+
 1;