Tony Mack | 7130ac3 | 2013-03-22 21:58:00 -0400 | [diff] [blame] | 1 | from django.db import models |
| 2 | |
| 3 | # Create your models here. |
| 4 | |
| 5 | class PlCoreBase(models.Model): |
| 6 | |
| 7 | created = models.DateTimeField(auto_now_add=True) |
| 8 | updated = models.DateTimeField(auto_now=True) |
| 9 | |
| 10 | class Meta: |
| 11 | abstract = True |
| 12 | |
| 13 | class Site(PlCoreBase): |
| 14 | name = models.CharField(max_length=200, unique=True, help_text="Name for this Site") |
| 15 | site_url = models.URLField(help_text="Site's Home URL Page") |
| 16 | enabled = models.BooleanField(default=True, help_text="Status for this Site") |
| 17 | longitude = models.FloatField(null=True, blank=True) |
| 18 | latitude = models.FloatField(null=True, blank=True) |
| 19 | login_base = models.CharField(max_length=50, help_text="Prefix for Slices associated with this Site") |
| 20 | is_public = models.BooleanField(default=True, help_text="Indicates the visibility of this site to other members") |
| 21 | abbreviated_name = models.CharField(max_length=80) |
| 22 | |
| 23 | def __unicode__(self): return u'%s' % (self.name) |
| 24 | |
| 25 | class Slice(PlCoreBase): |
| 26 | name = models.CharField(help_text="The Name of the Slice", max_length=80) |
| 27 | SLICE_CHOICES = (('plc', 'PLC'), ('delegated', 'Delegated'), ('controller','Controller'), ('none','None')) |
| 28 | instantiation = models.CharField(help_text="The instantiation type of the slice", max_length=80, choices=SLICE_CHOICES) |
| 29 | omf_friendly = models.BooleanField() |
| 30 | description=models.TextField(blank=True,help_text="High level description of the slice and expected activities", max_length=1024) |
| 31 | slice_url = models.URLField(blank=True) |
| 32 | site = models.ForeignKey(Site, related_name='slices', help_text="The Site this Node belongs too") |
| 33 | |
| 34 | def __unicode__(self): return u'%s' % (self.name) |
| 35 | |
| 36 | class DeploymentNetwork(PlCoreBase): |
| 37 | name = models.CharField(max_length=200, unique=True, help_text="Name of the Deployment Network") |
| 38 | |
| 39 | def __unicode__(self): return u'%s' % (self.name) |
| 40 | |
| 41 | class SiteDeploymentNetwork(PlCoreBase): |
| 42 | class Meta: |
| 43 | unique_together = ['site', 'deploymentNetwork'] |
| 44 | |
| 45 | site = models.ForeignKey(Site, related_name='deploymentNetworks') |
| 46 | deploymentNetwork = models.ForeignKey(DeploymentNetwork, related_name='sites') |
| 47 | name = models.CharField(default="Blah", max_length=100) |
| 48 | |
| 49 | |
| 50 | def __unicode__(self): return u'%s::%s' % (self.site, self.deploymentNetwork) |
| 51 | |
| 52 | |
| 53 | class Sliver(PlCoreBase): |
| 54 | name = models.CharField(max_length=200, unique=True) |
| 55 | slice = models.ForeignKey(Slice) |
| 56 | siteDeploymentNetwork = models.ForeignKey(SiteDeploymentNetwork) |
| 57 | |
| 58 | def __unicode__(self): return u'%s::%s' % (self.slice, self.siteDeploymentNetwork) |
| 59 | |
| 60 | class Node(PlCoreBase): |
| 61 | name = models.CharField(max_length=200, unique=True, help_text="Name of the Node") |
| 62 | siteDeploymentNetwork = models.ForeignKey(SiteDeploymentNetwork, help_text="The Site and Deployment Network this Node belongs too.") |
| 63 | |
| 64 | def __unicode__(self): return u'%s' % (self.name) |
| 65 | |