phase in vmhost

Signed-off-by: Nico Schottelius <nico@nico-notebook.schottelius.org>
This commit is contained in:
Nico Schottelius 2020-02-25 20:53:12 +01:00
commit d4b170f813
13 changed files with 280 additions and 51 deletions

View file

@ -1,20 +1,22 @@
from django.db import models
from django.contrib.auth import get_user_model
import uuid
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)
hostname = models.CharField(max_length=253, unique=True)
# indirectly gives a maximum number of cores / VM - f.i. 32
physical_cores = models.IntegerField()
physical_cores = models.IntegerField(default=0)
# determines the maximum usable cores - f.i. 320 if you overbook by a factor of 10
usable_cores = models.IntegerField()
usable_cores = models.IntegerField(default=0)
# ram that can be used of the server
usable_ram_in_gb = models.FloatField()
usable_ram_in_gb = models.FloatField(default=0)
status = models.CharField(max_length=32,
@ -22,24 +24,33 @@ class VMHost(models.Model):
('pending', 'Pending'),
('active', 'Active'),
('unusable', 'Unusable'),
('deleted', 'Deleted'),
),
default='pending'
)
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)
class VMProduct(models.Model):
uuid = models.UUIDField(primary_key=True,
default=uuid.uuid4,
editable=False)
owner = models.ForeignKey(get_user_model(),
on_delete=models.CASCADE,
editable=False)
vmhost = models.ForeignKey(VMHost,
on_delete=models.CASCADE,
editable=False)
cores = models.IntegerField()
ram_in_gb = models.FloatField()
vmhost = models.ForeignKey(VMHost, on_delete=models.CASCADE)
class VMWithOSProduct(VMProduct):
pass
class VMDisk(models.Model):
class VMDiskProduct(models.Model):
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
vm = models.ForeignKey(VM, on_delete=models.CASCADE)
vm = models.ForeignKey(VMProduct, on_delete=models.CASCADE)
size_in_gb = models.FloatField()
storage_class = models.CharField(max_length=32,
@ -49,3 +60,12 @@ class VMDisk(models.Model):
),
default='ssd'
)
class OperatingSystemDisk(VMDiskProduct):
""" Defines an Operating System Disk that can be cloned for a VM """
os_name = models.CharField(max_length=128)
class VMNetworkCard(models.Model):
vm = models.ForeignKey(VMProduct, on_delete=models.CASCADE)
mac_address = models.IntegerField()