models.py 3.14 KB
Newer Older
1 2 3
from django.db import models

class User(models.Model):
4 5
    id = models.CharField("UUID", primary_key=True, null=False, blank=False, unique=True, default="", max_length=255, help_text="Unique user id asign by Astakos")
    token = models.CharField("Okeanos Token", null=True, blank=True, unique=True, default="", max_length=64, help_text="Token provided by ~okeanos.")
6

7
class Project(models.Model):
efikalti's avatar
efikalti committed
8
    id = models.AutoField("Project ID", primary_key=True, null=False, blank=False, unique=True, default="", help_text="Project id provided by kamaki.")
9
    description = models.TextField("Project Description", null=True, blank=True, unique=False, default="", help_text="The description of a project.")
10

11
class Cluster(models.Model):
12
    id = models.AutoField("Cluster ID", primary_key=True, null=False, help_text="Auto-increment cluster id.")
13
    # OneToOneField is a ForeignKey with unique=True. Django recommends using OneToOneField instead of a ForeignKey
Georgios Ouzounis's avatar
Georgios Ouzounis committed
14 15
    # with unique=True.
    master_server = models.OneToOneField('Server', null=True, blank=True, on_delete=models.CASCADE)
16

efikalti's avatar
efikalti committed
17 18
class Server(models.Model):
    id = models.AutoField("Server ID", primary_key=True, null=False, blank=False, unique=True, default="", help_text="Server id provided by kamaki.")
Georgios Ouzounis's avatar
Georgios Ouzounis committed
19 20 21
    hostname = models.CharField("Hostname", null=False, blank=False, unique=True, max_length=100)
    public_ip = models.GenericIPAddressField("Public IP", null=False, blank=False, unique=True)
    private_ip = models.GenericIPAddressField("Private IP", null=False, blank=False, unique=False)
efikalti's avatar
efikalti committed
22 23 24 25

class PrivateNetwork(models.Model):
    id = models.AutoField("Network ID", primary_key=True, null=False, blank=False, unique=True, default="", help_text="Private network id provided by kamaki.")
    subnet = models.CharField(max_length=100)
Georgios Ouzounis's avatar
Georgios Ouzounis committed
26
    gateway = models.GenericIPAddressField("Gateway", null=False, blank=False, unique=False)
27 28 29

class UserProjectConnection(models.Model):
    user_id = models.ForeignKey('User', null=False, blank=False, unique=False, on_delete=models.CASCADE)
30
    project_id = models.ForeignKey('Project', null=False, blank=False, unique=False, on_delete=models.CASCADE)
31 32 33

class UserClusterConnection(models.Model):
    user_id = models.ForeignKey('User', null=False, blank=False, unique=False, on_delete=models.CASCADE)
34
    cluster_id = models.ForeignKey('Cluster', null=False, blank=False, unique=False, on_delete=models.CASCADE)
efikalti's avatar
efikalti committed
35 36 37

class ClusterServerConnection(models.Model):
    server_id = models.ForeignKey('Server', null=False, blank=False, unique=False, on_delete=models.CASCADE)
38
    cluster_id = models.ForeignKey('Cluster', null=False, blank=False, unique=False, on_delete=models.CASCADE)
efikalti's avatar
efikalti committed
39 40 41

class ClusterNetworkConnection(models.Model):
    network_id = models.ForeignKey('PrivateNetwork', null=False, blank=False, unique=False, on_delete=models.CASCADE)
42 43 44 45 46
    cluster_id = models.ForeignKey('Cluster', null=False, blank=False, unique=False, on_delete=models.CASCADE)

class ClusterProjectConnection(models.Model):
    network_id = models.ForeignKey('Project', null=False, blank=False, unique=False, on_delete=models.CASCADE)
    cluster_id = models.ForeignKey('Cluster', null=False, blank=False, unique=False, on_delete=models.CASCADE)