2 from django.db import models
3 from core.models import PlCoreBase, Site, Slice, Sliver
4 from django.contrib.contenttypes.models import ContentType
5 from django.contrib.contenttypes import generic
7 # Create your models here.
9 class NetworkTemplate(PlCoreBase):
10 VISIBILITY_CHOICES = (('public', 'public'), ('private', 'private'))
12 name = models.CharField(max_length=32)
13 guaranteedBandwidth = models.IntegerField(default=0)
14 visibility = models.CharField(max_length=30, choices=VISIBILITY_CHOICES, default="private")
16 def __unicode__(self): return u'%s' % (self.name)
18 class Network(PlCoreBase):
19 name = models.CharField(max_length=32)
20 template = models.ForeignKey(NetworkTemplate)
21 subnet = models.CharField(max_length=32)
22 ports = models.CharField(max_length=1024)
23 labels = models.CharField(max_length=1024)
24 slice = models.ForeignKey(Slice, related_name="networks")
26 guaranteedBandwidth = models.IntegerField(default=0)
27 permittedSlices = models.ManyToManyField(Slice, blank=True, related_name="permittedNetworks")
28 boundSlivers = models.ManyToManyField(Sliver, blank=True, related_name="boundNetworks", through="NetworkBoundSliver")
30 def __unicode__(self): return u'%s' % (self.name)
32 class NetworkBoundSliver(PlCoreBase):
33 network = models.ForeignKey(Network)
34 sliver = models.ForeignKey(Sliver)
35 ip = models.GenericIPAddressField(help_text="Sliver ip address", blank=True, null=True)
37 def __unicode__(self): return u'foo!'
39 class Router(PlCoreBase):
40 name = models.CharField(max_length=32)
41 owner = models.ForeignKey(Slice, related_name="routers")
42 networks = models.ManyToManyField(Network, blank=True, related_name="routers")
44 def __unicode__(self): return u'%s' % (self.name)
46 class NetworkParameterType(PlCoreBase):
47 name = models.SlugField(help_text="The name of this tag", max_length=128)
49 def __unicode__(self): return u'%s' % (self.name)
51 class NetworkParameter(PlCoreBase):
52 networkParameterType = models.ForeignKey(NetworkParameterType, related_name="parameters", help_text="The name of the parameter")
53 value = models.CharField(help_text="The value of this parameter", max_length=1024)
55 # The required fields to do a ObjectType lookup, and object_id assignment
56 content_type = models.ForeignKey(ContentType)
57 object_id = models.PositiveIntegerField()
58 content_object = generic.GenericForeignKey('content_type', 'object_id')
60 def __unicode__(self):
61 return self.networkParameterType.name