2020-02-23 13:07:37 +00:00
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
|
2020-02-23 16:43:06 +00:00
|
|
|
class VMHost(models.Model):
|
|
|
|
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
|
|
|
|
|
|
|
# 253 is the maximum DNS name length
|
|
|
|
hostname = models.CharField(max_length=253)
|
|
|
|
|
|
|
|
# indirectly gives a maximum number of cores / VM - f.i. 32
|
|
|
|
physical_cores = models.IntegerField()
|
|
|
|
|
|
|
|
# determines the maximum usable cores - f.i. 320 if you overbook by a factor of 10
|
|
|
|
usable_cores = models.IntegerField()
|
|
|
|
|
|
|
|
# ram that can be used of the server
|
|
|
|
usable_ram_in_gb = models.FloatField()
|
|
|
|
|
|
|
|
|
2020-02-23 13:07:37 +00:00
|
|
|
class VM(models.Model):
|
|
|
|
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
|
|
|
owner = models.ForeignKey(get_user_model(), on_delete=models.CASCADE)
|
|
|
|
|
|
|
|
cores = models.IntegerField()
|
2020-02-23 16:43:06 +00:00
|
|
|
ram_in_gb = models.FloatField()
|
|
|
|
|
|
|
|
vmhost = models.ForeignKey(VMHost, on_delete=models.CASCADE)
|
2020-02-23 13:07:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
class VMDisk(models.Model):
|
2020-02-23 16:43:06 +00:00
|
|
|
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
|
|
|
vm = models.ForeignKey(VM, on_delete=models.CASCADE)
|
|
|
|
size_in_gb = models.FloatField()
|
|
|
|
|
|
|
|
storage_class = models.CharField(max_length=32,
|
|
|
|
choices = (
|
|
|
|
('hdd', 'HDD'),
|
|
|
|
('ssd', 'SSD'),
|
|
|
|
),
|
|
|
|
default='ssd'
|
|
|
|
)
|