Merge branch 'master' of ssh://git.planet-lab.org/git/plstackapi
[plstackapi.git] / planetstack / core / models / site.py
index 1301ebf..bc4c5ca 100644 (file)
@@ -21,7 +21,7 @@ class Site(PlCoreBase):
     abbreviated_name = models.CharField(max_length=80)
 
     #deployments = models.ManyToManyField('Deployment', blank=True, related_name='sites')
-    deployments = models.ManyToManyField('Deployment', through='SiteDeployments', blank=True)
+    deployments = models.ManyToManyField('Deployment', through='SiteDeployments', blank=True, help_text="Select which sites are allowed to host nodes in this deployment", related_name='sites')
     tags = generic.GenericRelation(Tag)
 
     def __unicode__(self):  return u'%s' % (self.name)
@@ -83,6 +83,11 @@ class SitePrivilege(PlCoreBase):
 
 class Deployment(PlCoreBase):
     name = models.CharField(max_length=200, unique=True, help_text="Name of the Deployment")
+    admin_user = models.CharField(max_length=200, null=True, blank=True, help_text="Username of an admin user at this deployment")
+    admin_password = models.CharField(max_length=200, null=True, blank=True, help_text="Password of theadmin user at this deployment")\r
+    admin_tenant = models.CharField(max_length=200, null=True, blank=True, help_text="Name of the tenant the admin user belongs to")\r
+    auth_url = models.CharField(max_length=200, null=True, blank=True, help_text="Auth url for the deployment")
+    backend_type = models.CharField(max_length=200, null=True, blank=True, help_text="Type of deployment, e.g. EC2, OpenStack, or OpenStack version")
 
     # smbaker: the default of 'allow all' is intended for evolutions of existing
     #    deployments. When new deployments are created via the GUI, they are
@@ -112,13 +117,15 @@ class Deployment(PlCoreBase):
 
         return False
 
-    def select_by_acl(self, user):
-        acl = self.get_acl()
-        result = []
+    @staticmethod
+    def select_by_acl(user):
+        ids = []
         for deployment in Deployment.objects.all():
-            if acl.test(user):
-                result.append(deployment)
-        return result
+            acl = deployment.get_acl()
+            if acl.test(user) == "allow":
+                ids.append(deployment.id)
+
+        return Deployment.objects.filter(id__in=ids)
 
     def __unicode__(self):  return u'%s' % (self.name)