From 6a382fab23cdb26701faad33e4a0a83ae1ee43bf Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 17 Mar 2020 19:07:00 +0100 Subject: [PATCH] [vmhost] add used_ram_in_gb --- uncloud/uncloud_vm/models.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/uncloud/uncloud_vm/models.py b/uncloud/uncloud_vm/models.py index 2bb27e9..70ffd80 100644 --- a/uncloud/uncloud_vm/models.py +++ b/uncloud/uncloud_vm/models.py @@ -45,6 +45,10 @@ class VMHost(models.Model): def vms(self): return VMProduct.objects.filter(vmhost=self) + @property + def used_ram_in_gb(self): + return sum([vm.ram_in_gb for vm in VMProduct.objects.filter(vmhost=self)]) + @property def available_ram_in_gb(self): return self.usable_ram_in_gb - sum([vm.ram_in_gb for vm in self.vms ])