Scott Baker | 40695e1 | 2014-03-13 22:50:45 -0700 | [diff] [blame] | 1 | from core.models import User,Site,Service,SingletonModel,PlCoreBase, Slice |
Siobhan Tully | ce652d0 | 2013-10-08 21:52:35 -0400 | [diff] [blame] | 2 | import os |
| 3 | from django.db import models |
| 4 | from django.forms.models import model_to_dict |
| 5 | |
| 6 | # Create your models here. |
| 7 | |
| 8 | class RequestRouterService(SingletonModel,Service): |
| 9 | class Meta: |
| 10 | app_label = "requestrouter" |
| 11 | verbose_name = "Request Router Service" |
| 12 | |
| 13 | behindNat = models.BooleanField(default=False, help_text="Enables 'Behind NAT' mode.") |
| 14 | defaultTTL = models.PositiveIntegerField(default=30, help_text="DNS response time-to-live(TTL)") |
| 15 | defaultAction = models.CharField(max_length=30, default = "best", help_text="Review if this should be enum") |
| 16 | lastResortAction = models.CharField(max_length=30, default = "random", help_text="Review if this should be enum") |
| 17 | maxAnswers = models.PositiveIntegerField(default=3, help_text="Maximum number of answers in DNS response.") |
Scott Baker | 40695e1 | 2014-03-13 22:50:45 -0700 | [diff] [blame] | 18 | |
Scott Baker | 2290b05 | 2014-05-08 10:28:22 -0700 | [diff] [blame] | 19 | def __unicode__(self): return u'Request Router Service' |
Siobhan Tully | ce652d0 | 2013-10-08 21:52:35 -0400 | [diff] [blame] | 20 | |
Scott Baker | 2290b05 | 2014-05-08 10:28:22 -0700 | [diff] [blame] | 21 | class ServiceMap(PlCoreBase): |
| 22 | |
| 23 | class Meta: |
| 24 | app_label = "requestrouter" |
| 25 | |
Scott Baker | 40695e1 | 2014-03-13 22:50:45 -0700 | [diff] [blame] | 26 | name = models.SlugField(max_length=50, unique=True, blank=False, null=False, help_text="name of this service map") |
| 27 | owner = models.ForeignKey(Service, help_text="service which owns this map") |
| 28 | slice = models.ForeignKey(Slice, help_text="slice that implements this service") |
| 29 | prefix = models.CharField(max_length=256, help_text="FQDN of the region of URI space managed by RR on behalf of this service") |
Scott Baker | 2290b05 | 2014-05-08 10:28:22 -0700 | [diff] [blame] | 30 | # need to fix the upload location appropriately, for now we are not using access/site map |
| 31 | siteMap = models.FileField(upload_to="maps/", help_text="maps client requests to service instances", blank=True) |
| 32 | accessMap = models.FileField(upload_to="maps/", help_text="specifies which client requests are allowed", blank=True) |
Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 33 | |
Scott Baker | 40695e1 | 2014-03-13 22:50:45 -0700 | [diff] [blame] | 34 | def siteMapName(self): |
| 35 | return self.name + ".site" |
| 36 | |
| 37 | def accessMapName(self): |
| 38 | return self.name + ".access" |
| 39 | |
| 40 | def __unicode__(self): return u'%s' % self.name |
| 41 | |