[vmhost] add available_ram_in_gb and available_cores

This commit is contained in:
Nico Schottelius 2020-03-05 15:06:34 +01:00
parent 139aca6a61
commit b8c2f80e45

View file

@ -45,6 +45,14 @@ class VMHost(models.Model):
def vms(self):
return 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 ])
@property
def available_cores(self):
return self.usable_cores - sum([vm.cores for vm in self.vms ])
class VMProduct(Product):
vmhost = models.ForeignKey(