[vmhost] add used_ram_in_gb

This commit is contained in:
Nico Schottelius 2020-03-17 19:07:00 +01:00
parent b9473c1803
commit 6a382fab23

View file

@ -45,6 +45,10 @@ class VMHost(models.Model):
def vms(self): def vms(self):
return VMProduct.objects.filter(vmhost=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 @property
def available_ram_in_gb(self): def available_ram_in_gb(self):
return self.usable_ram_in_gb - sum([vm.ram_in_gb for vm in self.vms ]) return self.usable_ram_in_gb - sum([vm.ram_in_gb for vm in self.vms ])