summaryrefslogtreecommitdiffstats
path: root/tools/pharos-dashboard/dashboard/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/pharos-dashboard/dashboard/models.py')
-rw-r--r--tools/pharos-dashboard/dashboard/models.py85
1 files changed, 12 insertions, 73 deletions
diff --git a/tools/pharos-dashboard/dashboard/models.py b/tools/pharos-dashboard/dashboard/models.py
index 132ba7c6..973066b8 100644
--- a/tools/pharos-dashboard/dashboard/models.py
+++ b/tools/pharos-dashboard/dashboard/models.py
@@ -1,63 +1,14 @@
-from __future__ import unicode_literals
-
-from django.db import models
from django.contrib.auth.models import User
-
-
-class Booking(models.Model):
- booking_id = models.AutoField(primary_key=True)
- # Bookings should be deleted before resources
- resource = models.ForeignKey('Resource', models.PROTECT)
- # delete Booking when user is deleted
- user = models.ForeignKey(User, models.CASCADE)
- start_date_time = models.DateTimeField()
- end_date_time = models.DateTimeField()
- creation = models.DateTimeField(auto_now=True)
- purpose = models.CharField(max_length=300)
-
- class Meta:
- db_table = 'booking'
-
- # check for conflicting bookings before saving
- def save(self, *args, **kwargs):
- # conflicts end after booking starts, and start before booking ends
- conflicting_bookings = Booking.objects.filter(resource_id=self.resource_id)
- conflicting_bookings = conflicting_bookings.filter(end_date_time__gt=self.start_date_time)
- conflicting_bookings = conflicting_bookings.filter(start_date_time__lt=self.end_date_time)
- # we may change a booking, so it is not a conflict
- conflicting_bookings = conflicting_bookings.exclude(booking_id=self.booking_id)
- if conflicting_bookings.count() > 0:
- raise ValueError('This booking overlaps with another booking')
- super(Booking, self).save(*args, **kwargs)
-
-
-def __str__(self):
- return 'Booking: ' + str(self.resource)
-
-
-class Pod(models.Model):
- pod_id = models.AutoField(primary_key=True)
- # Delete Pod with resource
- resource = models.ForeignKey('Resource', models.CASCADE)
- chassis = models.CharField(max_length=500, blank=True, null=True)
-
- class Meta:
- db_table = 'pod'
-
- def __str__(self):
- if self.chassis is None:
- return str(self.pod_id) + ' ' + str(self.resource)
- return str(self.pod_id) + ' ' + self.chassis
+from django.db import models
class Resource(models.Model):
- resource_id = models.AutoField(primary_key=True)
+ id = models.AutoField(primary_key=True)
name = models.CharField(max_length=100, unique=True)
slavename = models.CharField(max_length=50, blank=True, null=True)
description = models.CharField(max_length=300, blank=True, null=True)
url = models.CharField(max_length=100, blank=True, null=True)
- bookable = models.BooleanField(default=False)
- active = models.BooleanField(default=True)
+ owners = models.ManyToManyField(User)
class Meta:
db_table = 'resource'
@@ -65,25 +16,13 @@ class Resource(models.Model):
def __str__(self):
return self.name
+class ResourceUtilization(models.Model):
+ POD_STATUS = {
+ 'online': 1,
+ 'idle': 2,
+ 'offline': 3
+ }
-class Server(models.Model):
- server_id = models.AutoField(primary_key=True)
- resource = models.ForeignKey(Resource, models.DO_NOTHING)
- model = models.CharField(max_length=200, blank=True, null=True)
- cpu = models.CharField(max_length=200, blank=True, null=True)
- ram = models.CharField(max_length=200, blank=True, null=True)
- storage = models.CharField(max_length=200, blank=True, null=True)
- count = models.IntegerField(default=1)
-
- class Meta:
- db_table = 'server'
-
-
-class UserResource(models.Model):
- user_resource_id = models.AutoField(primary_key=True)
- user = models.ForeignKey(User, models.CASCADE)
- # Delete if Resource is deleted
- resource = models.ForeignKey(Resource, models.CASCADE)
-
- class Meta:
- db_table = 'user_resource'
+ id = models.AutoField(primary_key=True)
+ timestamp = models.DateTimeField(auto_created=True)
+ pod_status = models.IntegerField() \ No newline at end of file