[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
1 changed files with 4 additions and 0 deletions

View File

@ -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 ])