Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 1 | import os |
| 2 | from django.db import models |
Sapan Bhatia | c1f20ef | 2014-09-22 18:47:53 -0400 | [diff] [blame] | 3 | from django.db.models import Q |
Sapan Bhatia | c6680c1 | 2014-09-19 16:47:07 -0400 | [diff] [blame] | 4 | from core.models import PlCoreBase,PlCoreBaseManager,PlCoreBaseDeletionManager |
Siobhan Tully | de5450d | 2013-06-21 11:35:33 -0400 | [diff] [blame] | 5 | from core.models import Tag |
| 6 | from django.contrib.contenttypes import generic |
Siobhan Tully | 567e3e6 | 2013-06-21 18:03:16 -0400 | [diff] [blame] | 7 | from geoposition.fields import GeopositionField |
Scott Baker | 5380c52 | 2014-06-06 14:49:43 -0700 | [diff] [blame] | 8 | from core.acl import AccessControlList |
Scott Baker | 76a840e | 2015-02-11 21:38:09 -0800 | [diff] [blame] | 9 | from xos.config import Config |
Sapan Bhatia | 699a044 | 2014-09-22 17:25:06 -0400 | [diff] [blame] | 10 | |
| 11 | config = Config() |
Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 12 | |
Tony Mack | f3bbe47 | 2014-11-30 15:33:35 -0500 | [diff] [blame] | 13 | class ControllerLinkDeletionManager(PlCoreBaseDeletionManager): |
Sapan Bhatia | 71058ec | 2014-09-19 16:48:36 -0400 | [diff] [blame] | 14 | def get_queryset(self): |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 15 | parent=super(ControllerLinkDeletionManager, self) |
Sapan Bhatia | b8cc114 | 2014-09-23 13:14:31 -0400 | [diff] [blame] | 16 | try: |
| 17 | backend_type = config.observer_backend_type |
| 18 | except AttributeError: |
| 19 | backend_type = None |
| 20 | |
| 21 | parent_queryset = parent.get_queryset() if hasattr(parent, "get_queryset") else parent.get_query_set() |
| 22 | if (backend_type): |
Tony Mack | f3bbe47 | 2014-11-30 15:33:35 -0500 | [diff] [blame] | 23 | return parent_queryset.filter(Q(controller__backend_type=backend_type)) |
Sapan Bhatia | 71058ec | 2014-09-19 16:48:36 -0400 | [diff] [blame] | 24 | else: |
Sapan Bhatia | b8cc114 | 2014-09-23 13:14:31 -0400 | [diff] [blame] | 25 | return parent_queryset |
Sapan Bhatia | 71058ec | 2014-09-19 16:48:36 -0400 | [diff] [blame] | 26 | |
| 27 | # deprecated in django 1.7 in favor of get_queryset(). |
| 28 | def get_query_set(self): |
| 29 | return self.get_queryset() |
| 30 | |
| 31 | |
Tony Mack | f3bbe47 | 2014-11-30 15:33:35 -0500 | [diff] [blame] | 32 | class ControllerDeletionManager(PlCoreBaseDeletionManager): |
Sapan Bhatia | 005d761 | 2014-09-19 16:48:11 -0400 | [diff] [blame] | 33 | def get_queryset(self): |
Tony Mack | f3bbe47 | 2014-11-30 15:33:35 -0500 | [diff] [blame] | 34 | parent=super(ControllerDeletionManager, self) |
Sapan Bhatia | b8cc114 | 2014-09-23 13:14:31 -0400 | [diff] [blame] | 35 | |
| 36 | try: |
| 37 | backend_type = config.observer_backend_type |
| 38 | except AttributeError: |
| 39 | backend_type = None |
| 40 | |
| 41 | parent_queryset = parent.get_queryset() if hasattr(parent, "get_queryset") else parent.get_query_set() |
| 42 | |
| 43 | if backend_type: |
Sapan Bhatia | b3c838a | 2014-10-08 09:38:21 -0400 | [diff] [blame] | 44 | return parent_queryset.filter(Q(backend_type=backend_type)) |
Sapan Bhatia | 005d761 | 2014-09-19 16:48:11 -0400 | [diff] [blame] | 45 | else: |
Sapan Bhatia | b8cc114 | 2014-09-23 13:14:31 -0400 | [diff] [blame] | 46 | return parent_queryset |
Sapan Bhatia | 005d761 | 2014-09-19 16:48:11 -0400 | [diff] [blame] | 47 | |
| 48 | # deprecated in django 1.7 in favor of get_queryset(). |
| 49 | def get_query_set(self): |
| 50 | return self.get_queryset() |
| 51 | |
Tony Mack | f3bbe47 | 2014-11-30 15:33:35 -0500 | [diff] [blame] | 52 | class ControllerLinkManager(PlCoreBaseManager): |
Sapan Bhatia | d8a6eb5 | 2014-09-19 16:47:40 -0400 | [diff] [blame] | 53 | def get_queryset(self): |
Tony Mack | f3bbe47 | 2014-11-30 15:33:35 -0500 | [diff] [blame] | 54 | parent=super(ControllerLinkManager, self) |
Sapan Bhatia | b8cc114 | 2014-09-23 13:14:31 -0400 | [diff] [blame] | 55 | |
| 56 | try: |
| 57 | backend_type = config.observer_backend_type |
| 58 | except AttributeError: |
| 59 | backend_type = None |
| 60 | |
| 61 | parent_queryset = parent.get_queryset() if hasattr(parent, "get_queryset") else parent.get_query_set() |
| 62 | |
| 63 | if backend_type: |
Tony Mack | f3bbe47 | 2014-11-30 15:33:35 -0500 | [diff] [blame] | 64 | return parent_queryset.filter(Q(controller__backend_type=backend_type)) |
Sapan Bhatia | d8a6eb5 | 2014-09-19 16:47:40 -0400 | [diff] [blame] | 65 | else: |
Sapan Bhatia | b8cc114 | 2014-09-23 13:14:31 -0400 | [diff] [blame] | 66 | return parent_queryset |
Sapan Bhatia | d8a6eb5 | 2014-09-19 16:47:40 -0400 | [diff] [blame] | 67 | |
| 68 | # deprecated in django 1.7 in favor of get_queryset(). |
| 69 | def get_query_set(self): |
| 70 | return self.get_queryset() |
| 71 | |
| 72 | |
Tony Mack | f3bbe47 | 2014-11-30 15:33:35 -0500 | [diff] [blame] | 73 | class ControllerManager(PlCoreBaseManager): |
Sapan Bhatia | c6680c1 | 2014-09-19 16:47:07 -0400 | [diff] [blame] | 74 | def get_queryset(self): |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 75 | parent=super(ControllerManager, self) |
Sapan Bhatia | b8cc114 | 2014-09-23 13:14:31 -0400 | [diff] [blame] | 76 | |
| 77 | try: |
| 78 | backend_type = config.observer_backend_type |
| 79 | except AttributeError: |
| 80 | backend_type = None |
| 81 | |
| 82 | parent_queryset = parent.get_queryset() if hasattr(parent, "get_queryset") else parent.get_query_set() |
| 83 | |
| 84 | if backend_type: |
Sapan Bhatia | b3c838a | 2014-10-08 09:38:21 -0400 | [diff] [blame] | 85 | return parent_queryset.filter(Q(backend_type=backend_type)) |
Sapan Bhatia | c6680c1 | 2014-09-19 16:47:07 -0400 | [diff] [blame] | 86 | else: |
Sapan Bhatia | 90025d7 | 2014-09-24 00:34:44 -0400 | [diff] [blame] | 87 | return parent_queryset |
Sapan Bhatia | c6680c1 | 2014-09-19 16:47:07 -0400 | [diff] [blame] | 88 | |
| 89 | # deprecated in django 1.7 in favor of get_queryset(). |
| 90 | def get_query_set(self): |
| 91 | return self.get_queryset() |
| 92 | |
Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 93 | class Site(PlCoreBase): |
Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 94 | """ |
| 95 | A logical grouping of Nodes that are co-located at the same geographic location, which also typically corresponds to the Nodes' location in the physical network. |
| 96 | """ |
Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 97 | name = models.CharField(max_length=200, help_text="Name for this Site") |
| 98 | site_url = models.URLField(null=True, blank=True, max_length=512, help_text="Site's Home URL Page") |
| 99 | enabled = models.BooleanField(default=True, help_text="Status for this Site") |
Siobhan Tully | 567e3e6 | 2013-06-21 18:03:16 -0400 | [diff] [blame] | 100 | location = GeopositionField() |
Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 101 | longitude = models.FloatField(null=True, blank=True) |
| 102 | latitude = models.FloatField(null=True, blank=True) |
| 103 | login_base = models.CharField(max_length=50, unique=True, help_text="Prefix for Slices associated with this Site") |
| 104 | is_public = models.BooleanField(default=True, help_text="Indicates the visibility of this site to other members") |
| 105 | abbreviated_name = models.CharField(max_length=80) |
| 106 | |
Tony Mack | e4be32f | 2014-03-11 20:45:25 -0400 | [diff] [blame] | 107 | #deployments = models.ManyToManyField('Deployment', blank=True, related_name='sites') |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 108 | deployments = models.ManyToManyField('Deployment', through='SiteDeployment', blank=True, help_text="Select which sites are allowed to host nodes in this deployment", related_name='sites') |
Siobhan Tully | de5450d | 2013-06-21 11:35:33 -0400 | [diff] [blame] | 109 | tags = generic.GenericRelation(Tag) |
Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 110 | |
| 111 | def __unicode__(self): return u'%s' % (self.name) |
| 112 | |
Tony Mack | 5b06147 | 2014-02-04 07:57:10 -0500 | [diff] [blame] | 113 | def can_update(self, user): |
Tony Mack | 5ff90fc | 2015-02-08 21:38:41 -0500 | [diff] [blame] | 114 | return user.can_update_site(self, allow=['pi']) |
Tony Mack | 5b06147 | 2014-02-04 07:57:10 -0500 | [diff] [blame] | 115 | |
Siobhan Tully | bfd11dc | 2013-09-03 12:59:24 -0400 | [diff] [blame] | 116 | class SiteRole(PlCoreBase): |
| 117 | |
Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 118 | ROLE_CHOICES = (('admin','Admin'),('pi','PI'),('tech','Tech'),('billing','Billing')) |
Siobhan Tully | bfd11dc | 2013-09-03 12:59:24 -0400 | [diff] [blame] | 119 | role = models.CharField(choices=ROLE_CHOICES, unique=True, max_length=30) |
| 120 | |
| 121 | def __unicode__(self): return u'%s' % (self.role) |
| 122 | |
Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 123 | class SitePrivilege(PlCoreBase): |
| 124 | |
Sapan Bhatia | 13d2db9 | 2014-11-11 21:47:45 -0500 | [diff] [blame] | 125 | user = models.ForeignKey('User', related_name='siteprivileges') |
| 126 | site = models.ForeignKey('Site', related_name='siteprivileges') |
| 127 | role = models.ForeignKey('SiteRole',related_name='siteprivileges') |
Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 128 | |
| 129 | def __unicode__(self): return u'%s %s %s' % (self.site, self.user, self.role) |
| 130 | |
Tony Mack | 00d361f | 2013-04-28 10:28:42 -0400 | [diff] [blame] | 131 | def save(self, *args, **kwds): |
Tony Mack | 00d361f | 2013-04-28 10:28:42 -0400 | [diff] [blame] | 132 | super(SitePrivilege, self).save(*args, **kwds) |
| 133 | |
| 134 | def delete(self, *args, **kwds): |
Tony Mack | 00d361f | 2013-04-28 10:28:42 -0400 | [diff] [blame] | 135 | super(SitePrivilege, self).delete(*args, **kwds) |
| 136 | |
Tony Mack | 5b06147 | 2014-02-04 07:57:10 -0500 | [diff] [blame] | 137 | def can_update(self, user): |
Tony Mack | 5ff90fc | 2015-02-08 21:38:41 -0500 | [diff] [blame] | 138 | return user.can_update_site(self, allow=['pi']) |
Tony Mack | 5b06147 | 2014-02-04 07:57:10 -0500 | [diff] [blame] | 139 | |
Tony Mack | 5b06147 | 2014-02-04 07:57:10 -0500 | [diff] [blame] | 140 | @staticmethod |
| 141 | def select_by_user(user): |
| 142 | if user.is_admin: |
| 143 | qs = SitePrivilege.objects.all() |
| 144 | else: |
| 145 | sp_ids = [sp.id for sp in SitePrivilege.objects.filter(user=user)] |
| 146 | qs = SitePrivilege.objects.filter(id__in=sp_ids) |
| 147 | return qs |
| 148 | |
Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 149 | class Deployment(PlCoreBase): |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 150 | #objects = Controllermanager() |
Tony Mack | f3bbe47 | 2014-11-30 15:33:35 -0500 | [diff] [blame] | 151 | #deleted_objects = DeploymentDeletionManager() |
Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 152 | name = models.CharField(max_length=200, unique=True, help_text="Name of the Deployment") |
Tony Mack | f3bbe47 | 2014-11-30 15:33:35 -0500 | [diff] [blame] | 153 | #admin_user = models.CharField(max_length=200, null=True, blank=True, help_text="Username of an admin user at this deployment") |
| 154 | #admin_password = models.CharField(max_length=200, null=True, blank=True, help_text="Password of theadmin user at this deployment")
|
| 155 | #admin_tenant = models.CharField(max_length=200, null=True, blank=True, help_text="Name of the tenant the admin user belongs to")
|
| 156 | #auth_url = models.CharField(max_length=200, null=True, blank=True, help_text="Auth url for the deployment") |
| 157 | #backend_type = models.CharField(max_length=200, null=True, blank=True, help_text="Type of deployment, e.g. EC2, OpenStack, or OpenStack version") |
| 158 | #availability_zone = models.CharField(max_length=200, null=True, blank=True, help_text="OpenStack availability zone") |
Scott Baker | 5380c52 | 2014-06-06 14:49:43 -0700 | [diff] [blame] | 159 | |
| 160 | # smbaker: the default of 'allow all' is intended for evolutions of existing |
| 161 | # deployments. When new deployments are created via the GUI, they are |
| 162 | # given a default of 'allow site <site_of_creator>' |
| 163 | accessControl = models.TextField(max_length=200, blank=False, null=False, default="allow all", |
| 164 | help_text="Access control list that specifies which sites/users may use nodes in this deployment") |
| 165 | |
| 166 | def get_acl(self): |
| 167 | return AccessControlList(self.accessControl) |
| 168 | |
| 169 | def test_acl(self, slice=None, user=None): |
| 170 | potential_users=[] |
| 171 | |
| 172 | if user: |
| 173 | potential_users.append(user) |
| 174 | |
| 175 | if slice: |
| 176 | potential_users.append(slice.creator) |
Sapan Bhatia | 900baf9 | 2014-11-11 21:10:07 -0500 | [diff] [blame] | 177 | for priv in slice.sliceprivileges.all(): |
Scott Baker | 5380c52 | 2014-06-06 14:49:43 -0700 | [diff] [blame] | 178 | if priv.user not in potential_users: |
| 179 | potential_users.append(priv.user) |
| 180 | |
| 181 | acl = self.get_acl() |
| 182 | for user in potential_users: |
| 183 | if acl.test(user) == "allow": |
| 184 | return True |
| 185 | |
| 186 | return False |
| 187 | |
Scott Baker | cb95fde | 2014-06-06 16:09:51 -0700 | [diff] [blame] | 188 | @staticmethod |
| 189 | def select_by_acl(user): |
| 190 | ids = [] |
Scott Baker | 5380c52 | 2014-06-06 14:49:43 -0700 | [diff] [blame] | 191 | for deployment in Deployment.objects.all(): |
Scott Baker | cb95fde | 2014-06-06 16:09:51 -0700 | [diff] [blame] | 192 | acl = deployment.get_acl() |
Scott Baker | 01a4cd0 | 2014-06-09 13:12:40 -0700 | [diff] [blame] | 193 | if acl.test(user) == "allow": |
Scott Baker | cb95fde | 2014-06-06 16:09:51 -0700 | [diff] [blame] | 194 | ids.append(deployment.id) |
| 195 | |
| 196 | return Deployment.objects.filter(id__in=ids) |
Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 197 | |
Tony Mack | d893dfb | 2015-02-05 06:13:04 -0500 | [diff] [blame] | 198 | def can_update(self, user): |
S.Çağlar Onur | feb377f | 2015-02-09 14:53:40 -0500 | [diff] [blame] | 199 | return user.can_update_deployment(self) |
Tony Mack | 5ff90fc | 2015-02-08 21:38:41 -0500 | [diff] [blame] | 200 | |
Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 201 | def __unicode__(self): return u'%s' % (self.name) |
| 202 | |
Tony Mack | 93d1b03 | 2014-12-08 16:43:02 -0500 | [diff] [blame] | 203 | class DeploymentRole(PlCoreBase): |
| 204 | #objects = DeploymentLinkManager() |
| 205 | #deleted_objects = DeploymentLinkDeletionManager() |
| 206 | ROLE_CHOICES = (('admin','Admin'),) |
| 207 | role = models.CharField(choices=ROLE_CHOICES, unique=True, max_length=30) |
| 208 | |
| 209 | def __unicode__(self): return u'%s' % (self.role) |
| 210 | |
| 211 | class DeploymentPrivilege(PlCoreBase): |
| 212 | #objects = DeploymentLinkManager() |
| 213 | #deleted_objects = DeploymentLinkDeletionManager() |
| 214 | |
| 215 | user = models.ForeignKey('User', related_name='deploymentprivileges') |
| 216 | deployment = models.ForeignKey('Deployment', related_name='deploymentprivileges') |
| 217 | role = models.ForeignKey('DeploymentRole',related_name='deploymentprivileges') |
| 218 | |
| 219 | def __unicode__(self): return u'%s %s %s' % (self.deployment, self.user, self.role) |
| 220 | |
| 221 | def can_update(self, user): |
S.Çağlar Onur | feb377f | 2015-02-09 14:53:40 -0500 | [diff] [blame] | 222 | return user.can_update_deployment(self) |
Tony Mack | 93d1b03 | 2014-12-08 16:43:02 -0500 | [diff] [blame] | 223 | |
| 224 | @staticmethod |
| 225 | def select_by_user(user): |
| 226 | if user.is_admin: |
| 227 | qs = DeploymentPrivilege.objects.all() |
| 228 | else: |
| 229 | dpriv_ids = [dp.id for dp in DeploymentPrivilege.objects.filter(user=user)] |
| 230 | qs = DeploymentPrivilege.objects.filter(id__in=dpriv_ids) |
| 231 | return qs |
| 232 | |
Tony Mack | f3bbe47 | 2014-11-30 15:33:35 -0500 | [diff] [blame] | 233 | class ControllerRole(PlCoreBase): |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 234 | #objects = ControllerLinkManager() |
| 235 | #deleted_objects = ControllerLinkDeletionManager() |
Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 236 | |
| 237 | ROLE_CHOICES = (('admin','Admin'),) |
| 238 | role = models.CharField(choices=ROLE_CHOICES, unique=True, max_length=30) |
| 239 | |
| 240 | def __unicode__(self): return u'%s' % (self.role) |
| 241 | |
Tony Mack | 528d422 | 2014-12-05 17:13:08 -0500 | [diff] [blame] | 242 | class Controller(PlCoreBase): |
| 243 | |
Tony Mack | f3bbe47 | 2014-11-30 15:33:35 -0500 | [diff] [blame] | 244 | objects = ControllerManager() |
| 245 | deleted_objects = ControllerDeletionManager() |
Sapan Bhatia | 6fc6e2b | 2014-09-22 14:54:56 -0400 | [diff] [blame] | 246 | |
Tony Mack | 528d422 | 2014-12-05 17:13:08 -0500 | [diff] [blame] | 247 | name = models.CharField(max_length=200, unique=True, help_text="Name of the Controller") |
Tony Mack | 78d4c3d | 2015-01-19 15:05:42 -0500 | [diff] [blame] | 248 | backend_type = models.CharField(max_length=200, help_text="Type of compute controller, e.g. EC2, OpenStack, or OpenStack version") |
Tony Mack | 2656436 | 2015-01-06 17:49:25 -0500 | [diff] [blame] | 249 | version = models.CharField(max_length=200, help_text="Controller version") |
Tony Mack | f3bbe47 | 2014-11-30 15:33:35 -0500 | [diff] [blame] | 250 | auth_url = models.CharField(max_length=200, null=True, blank=True, help_text="Auth url for the compute controller") |
| 251 | admin_user = models.CharField(max_length=200, null=True, blank=True, help_text="Username of an admin user at this controller") |
| 252 | admin_password = models.CharField(max_length=200, null=True, blank=True, help_text="Password of theadmin user at this controller") |
| 253 | admin_tenant = models.CharField(max_length=200, null=True, blank=True, help_text="Name of the tenant the admin user belongs to") |
Tony Mack | 4cea77e | 2015-02-10 12:43:07 -0500 | [diff] [blame] | 254 | domain = models.CharField(max_length=200, null=True, blank=True, help_text="Name of the domain this controller belongs to") |
Tony Mack | 7b6400d | 2015-02-16 19:54:24 -0500 | [diff] [blame] | 255 | deployment = models.ForeignKey(Deployment,related_name='controllerdeployments') |
Tony Mack | 79e2e66 | 2015-02-18 11:41:36 -0500 | [diff] [blame] | 256 | |
Tony Mack | f3bbe47 | 2014-11-30 15:33:35 -0500 | [diff] [blame] | 257 | |
Tony Mack | cd8f875 | 2014-12-26 12:15:42 -0500 | [diff] [blame] | 258 | def __unicode__(self): return u'%s %s %s' % (self.name, self.backend_type, self.version) |
Tony Mack | f3bbe47 | 2014-11-30 15:33:35 -0500 | [diff] [blame] | 259 | |
Tony Mack | 79e2e66 | 2015-02-18 11:41:36 -0500 | [diff] [blame] | 260 | @staticmethod |
| 261 | def select_by_user(user): |
| 262 | |
| 263 | if user.is_admin: |
| 264 | qs = Controller.objects.all() |
| 265 | else: |
| 266 | deployments = [dp.deployment for dp in DeploymentPrivilege.objects.filter(user=user, role__role__in=['Admin', 'admin'])] |
| 267 | qs = Controller.objects.filter(deployment__in=deployments) |
Tony Mack | 8b9975e | 2015-02-18 13:54:58 -0500 | [diff] [blame] | 268 | return qs |
Tony Mack | 79e2e66 | 2015-02-18 11:41:36 -0500 | [diff] [blame] | 269 | |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 270 | class SiteDeployment(PlCoreBase): |
Tony Mack | f3bbe47 | 2014-11-30 15:33:35 -0500 | [diff] [blame] | 271 | objects = ControllerLinkManager() |
Tony Mack | 528d422 | 2014-12-05 17:13:08 -0500 | [diff] [blame] | 272 | deleted_objects = ControllerLinkDeletionManager() |
Tony Mack | f3bbe47 | 2014-11-30 15:33:35 -0500 | [diff] [blame] | 273 | |
Tony Mack | 3c01ff9 | 2015-01-10 23:08:10 -0500 | [diff] [blame] | 274 | site = models.ForeignKey(Site,related_name='sitedeployments') |
| 275 | deployment = models.ForeignKey(Deployment,related_name='sitedeployments') |
| 276 | controller = models.ForeignKey(Controller, null=True, blank=True, related_name='sitedeployments') |
Tony Mack | 528d422 | 2014-12-05 17:13:08 -0500 | [diff] [blame] | 277 | availability_zone = models.CharField(max_length=200, null=True, blank=True, help_text="OpenStack availability zone") |
Tony Mack | 528d422 | 2014-12-05 17:13:08 -0500 | [diff] [blame] | 278 | |
Tony Mack | 7f542c6 | 2015-01-03 17:26:06 -0500 | [diff] [blame] | 279 | def __unicode__(self): return u'%s %s' % (self.deployment, self.site) |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 280 | |
| 281 | class ControllerSite(PlCoreBase): |
| 282 | |
| 283 | site = models.ForeignKey(Site,related_name='controllersite') |
| 284 | controller = models.ForeignKey(Controller, null=True, blank=True, related_name='controllersite') |
| 285 | tenant_id = models.CharField(null=True, blank=True, max_length=200, db_index=True, help_text="Keystone tenant id") |