blob: 8e4cc431d359bdb800d4e00540105aac2595abfa [file] [log] [blame]
Scott Baker40695e12014-03-13 22:50:45 -07001from core.models import User,Site,Service,SingletonModel,PlCoreBase, Slice
Siobhan Tullyce652d02013-10-08 21:52:35 -04002import os
3from django.db import models
4from django.forms.models import model_to_dict
5
6# Create your models here.
7
8class 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 Baker40695e12014-03-13 22:50:45 -070018
Scott Baker2290b052014-05-08 10:28:22 -070019 def __unicode__(self): return u'Request Router Service'
Siobhan Tullyce652d02013-10-08 21:52:35 -040020
Scott Baker2290b052014-05-08 10:28:22 -070021class ServiceMap(PlCoreBase):
22
23 class Meta:
24 app_label = "requestrouter"
25
Scott Baker40695e12014-03-13 22:50:45 -070026 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 Baker2290b052014-05-08 10:28:22 -070030 # 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 Tullycf04fb62014-01-11 11:25:57 -050033
Scott Baker40695e12014-03-13 22:50:45 -070034 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