forked from uncloud/uncloud
[vmhost] add available_ram_in_gb and available_cores
This commit is contained in:
parent
139aca6a61
commit
b8c2f80e45
1 changed files with 8 additions and 0 deletions
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue