Merge branch 'master' of ssh://git.planet-lab.org/git/plstackapi
[plstackapi.git] / planetstack / requestrouter / models.py
index 4350030..8e4cc43 100644 (file)
@@ -1,4 +1,4 @@
-from core.models import User,Site,Service,SingletonModel,PlCoreBase
+from core.models import User,Site,Service,SingletonModel,PlCoreBase, Slice
 import os
 from django.db import models
 from django.forms.models import model_to_dict
@@ -15,13 +15,27 @@ class RequestRouterService(SingletonModel,Service):
     defaultAction = models.CharField(max_length=30, default = "best", help_text="Review if this should be enum")
     lastResortAction = models.CharField(max_length=30, default = "random", help_text="Review if this should be enum")
     maxAnswers = models.PositiveIntegerField(default=3, help_text="Maximum number of answers in DNS response.")
-    
-    def __unicode__(self):  return u'RequestRouterService'
 
-class ClientMap(models.Model):
-    site = models.OneToOneField(Site, unique=True)
-    name = models.CharField(max_length=64, help_text="Name of the Client Map")
-    description = models.TextField(null=True, blank=True,max_length=130)
+    def __unicode__(self):  return u'Request Router Service'
+
+class ServiceMap(PlCoreBase):
+
+    class Meta:
+        app_label = "requestrouter"
+
+    name = models.SlugField(max_length=50, unique=True, blank=False, null=False, help_text="name of this service map")
+    owner = models.ForeignKey(Service, help_text="service which owns this map")
+    slice = models.ForeignKey(Slice, help_text="slice that implements this service")
+    prefix = models.CharField(max_length=256, help_text="FQDN of the region of URI space managed by RR on behalf of this service")
+       # need to fix the upload location appropriately, for now we are not using access/site map
+    siteMap = models.FileField(upload_to="maps/", help_text="maps client requests to service instances", blank=True)
+    accessMap = models.FileField(upload_to="maps/", help_text="specifies which client requests are allowed", blank=True)
+
+    def siteMapName(self):
+        return self.name + ".site"
+
+    def accessMapName(self):
+        return self.name + ".access"
+
+    def __unicode__(self): return u'%s' % self.name
 
-    def __unicode__(self):  return self.name
-