1 from core.models import User,Site,Service,SingletonModel,PlCoreBase, Slice
3 from django.db import models
4 from django.forms.models import model_to_dict
6 # Create your models here.
8 class RequestRouterService(SingletonModel,Service):
10 app_label = "requestrouter"
11 verbose_name = "Request Router Service"
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.")
19 def __unicode__(self): return u'Request Router Service'
21 class ServiceMap(PlCoreBase):
24 app_label = "requestrouter"
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")
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)
34 def siteMapName(self):
35 return self.name + ".site"
37 def accessMapName(self):
38 return self.name + ".access"
40 def __unicode__(self): return u'%s' % self.name