blob: 1b80cc6bccc9d8221c9543acf5c9116e3286f245 [file] [log] [blame]
Siobhan Tullybfd11dc2013-09-03 12:59:24 -04001from django.db import models
Siobhan Tullycf04fb62014-01-11 11:25:57 -05002from core.models import User, Service, SingletonModel, PlCoreBase
Siobhan Tullybfd11dc2013-09-03 12:59:24 -04003import os
4from django.db import models
5from django.forms.models import model_to_dict
6
7
8# Create your models here.
9
Siobhan Tullycf04fb62014-01-11 11:25:57 -050010class HpcService(SingletonModel,Service):
Siobhan Tullybfd11dc2013-09-03 12:59:24 -040011
12 class Meta:
Siobhan Tullybfd11dc2013-09-03 12:59:24 -040013 app_label = "hpc"
Siobhan Tullycf04fb62014-01-11 11:25:57 -050014 verbose_name = "HPC Service"
Siobhan Tullybfd11dc2013-09-03 12:59:24 -040015
Siobhan Tullycf04fb62014-01-11 11:25:57 -050016class ServiceProvider(PlCoreBase):
17 class Meta:
18 app_label = "hpc"
Scott Bakere728c892014-01-12 11:41:09 -080019
20 service_provider_id = models.IntegerField(null=True, blank=True)
Siobhan Tullybfd11dc2013-09-03 12:59:24 -040021 name = models.CharField(max_length=254,help_text="Service Provider Name")
22 description = models.TextField(max_length=254,null=True, blank=True, help_text="Description of Service Provider")
23 enabled = models.BooleanField(default=True)
24
25 def __unicode__(self): return u'%s' % (self.name)
26
Siobhan Tullycf04fb62014-01-11 11:25:57 -050027class ContentProvider(PlCoreBase):
28 class Meta:
29 app_label = "hpc"
Scott Bakere728c892014-01-12 11:41:09 -080030
31 content_provider_id = models.IntegerField(null=True, blank=True)
Siobhan Tullybfd11dc2013-09-03 12:59:24 -040032 name = models.CharField(max_length=254)
33 enabled = models.BooleanField(default=True)
34 description = models.TextField(max_length=254,null=True, blank=True,help_text="Description of Content Provider")
35 serviceProvider = models.ForeignKey(ServiceProvider)
36
37 # Note user relationships are directed not requiring a role.
38 users = models.ManyToManyField(User)
39
40 def __unicode__(self): return u'%s' % (self.name)
41
Siobhan Tullycf04fb62014-01-11 11:25:57 -050042class OriginServer(PlCoreBase):
43 class Meta:
44 app_label = "hpc"
Scott Bakere728c892014-01-12 11:41:09 -080045
46 origin_server_id = models.IntegerField(null=True, blank=True)
Siobhan Tullybfd11dc2013-09-03 12:59:24 -040047 url = models.URLField()
48 contentProvider = models.ForeignKey(ContentProvider)
49
50 authenticated = models.BooleanField(default=False, help_text="Status for this Site")
51 enabled = models.BooleanField(default=True, help_text="Status for this Site")
52 PROTOCOL_CHOICES = (('http', 'HTTP'),('rtmp', 'RTMP'), ('rtp', 'RTP'),('shout', 'SHOUTcast'))
53 protocol = models.CharField(default="HTTP", max_length = 12, choices=PROTOCOL_CHOICES)
54 redirects = models.BooleanField(default=True, help_text="Indicates whether Origin Server redirects should be used for this Origin Server")
55 description = models.TextField(null=True, blank=True, max_length=255)
56
57 def __unicode__(self): return u'%s' % (self.url)
58
Siobhan Tullycf04fb62014-01-11 11:25:57 -050059class CDNPrefix(PlCoreBase):
60 class Meta:
61 app_label = "hpc"
Scott Bakere728c892014-01-12 11:41:09 -080062
63 cdn_prefix_id = models.IntegerField(null=True, blank=True)
Siobhan Tullybfd11dc2013-09-03 12:59:24 -040064 prefix = models.CharField(max_length=200, help_text="Registered Prefix for Domain")
65 contentProvider = models.ForeignKey(ContentProvider)
66 description = models.TextField(max_length=254,null=True, blank=True,help_text="Description of Content Provider")
67
68 defaultOriginServer = models.ForeignKey(OriginServer)
69 enabled = models.BooleanField(default=True)
70
71 def __unicode__(self): return u'%s' % (self.prefix)
72
Scott Baker53491082014-03-13 23:15:19 -070073class AccessMap(models.Model):
74 contentProvider = models.ForeignKey(ContentProvider)
75 name = models.CharField(max_length=64, help_text="Name of the Access Map")
76 description = models.TextField(null=True, blank=True,max_length=130)
77 map = models.FileField(upload_to="maps/", help_text="specifies which client requests are allowed")
78
79 def __unicode__(self): return self.name
80
81class SiteMap(models.Model):
82 """ can be bound to a ContentProvider, ServiceProvider, or neither """
83 contentProvider = models.ForeignKey(ContentProvider, blank=True, null=True)
84 serviceProvider = models.ForeignKey(ServiceProvider, blank=True, null=True)
85 name = models.CharField(max_length=64, help_text="Name of the Site Map")
86 description = models.TextField(null=True, blank=True,max_length=130)
87 map = models.FileField(upload_to="maps/", help_text="specifies how to map requests to hpc instances")
88
89 def __unicode__(self): return self.name