rename NetworkBoundSliver to NetworkSliver
[plstackapi.git] / planetstack / core / models / network.py
1 import os
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
6
7 # Create your models here.
8
9 class NetworkTemplate(PlCoreBase):
10     VISIBILITY_CHOICES = (('public', 'public'), ('private', 'private'))
11
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")
15
16     def __unicode__(self):  return u'%s' % (self.name)
17
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")
25
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="NetworkSliver")
29
30     def __unicode__(self):  return u'%s' % (self.name)
31
32 class NetworkSliver(PlCoreBase):
33     network = models.ForeignKey(Network)
34     sliver = models.ForeignKey(Sliver)
35     ip = models.GenericIPAddressField(help_text="Sliver ip address", blank=True, null=True)
36
37     def __unicode__(self):  return u'foo!'
38
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")
43
44     def __unicode__(self):  return u'%s' % (self.name)
45
46 class NetworkParameterType(PlCoreBase):
47     name = models.SlugField(help_text="The name of this tag", max_length=128)
48
49     def __unicode__(self):  return u'%s' % (self.name)
50
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)
54
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')
59
60     def __unicode__(self):
61         return self.networkParameterType.name
62
63