Scott Baker | 58a9c7a | 2013-07-29 15:43:07 -0700 | [diff] [blame] | 1 | import os |
| 2 | import socket |
Scott Baker | bf7bc4a | 2015-01-06 15:11:29 -0800 | [diff] [blame] | 3 | import sys |
Scott Baker | 58a9c7a | 2013-07-29 15:43:07 -0700 | [diff] [blame] | 4 | from django.db import models |
Tony Mack | f3bbe47 | 2014-11-30 15:33:35 -0500 | [diff] [blame] | 5 | from core.models import PlCoreBase, Site, Slice, Sliver, Controller |
| 6 | from core.models import ControllerLinkManager,ControllerLinkDeletionManager |
Scott Baker | 58a9c7a | 2013-07-29 15:43:07 -0700 | [diff] [blame] | 7 | from django.contrib.contenttypes.models import ContentType |
| 8 | from django.contrib.contenttypes import generic |
Scott Baker | 198fda1 | 2014-10-17 16:22:20 -0700 | [diff] [blame] | 9 | from django.core.exceptions import ValidationError |
Scott Baker | 58a9c7a | 2013-07-29 15:43:07 -0700 | [diff] [blame] | 10 | |
| 11 | # If true, then IP addresses will be allocated by the model. If false, then |
| 12 | # we will assume the observer handles it. |
Scott Baker | 026bfe7 | 2013-07-29 16:03:50 -0700 | [diff] [blame] | 13 | NO_OBSERVER=False |
Scott Baker | 58a9c7a | 2013-07-29 15:43:07 -0700 | [diff] [blame] | 14 | |
Scott Baker | 198fda1 | 2014-10-17 16:22:20 -0700 | [diff] [blame] | 15 | def ParseNatList(ports): |
| 16 | """ Support a list of ports in the format "protocol:port, protocol:port, ..." |
| 17 | examples: |
| 18 | tcp 123 |
| 19 | tcp 123:133 |
| 20 | tcp 123, tcp 124, tcp 125, udp 201, udp 202 |
| 21 | |
| 22 | User can put either a "/" or a " " between protocol and ports |
| 23 | Port ranges can be specified with "-" or ":" |
| 24 | """ |
| 25 | nats = [] |
| 26 | if ports: |
| 27 | parts = ports.split(",") |
| 28 | for part in parts: |
| 29 | part = part.strip() |
| 30 | if "/" in part: |
| 31 | (protocol, ports) = part.split("/",1) |
| 32 | elif " " in part: |
| 33 | (protocol, ports) = part.split(None,1) |
| 34 | else: |
| 35 | raise TypeError('malformed port specifier %s, format example: "tcp 123, tcp 201:206, udp 333"' % part) |
| 36 | |
| 37 | protocol = protocol.strip() |
| 38 | ports = ports.strip() |
| 39 | |
| 40 | if not (protocol in ["udp", "tcp"]): |
| 41 | raise ValueError('unknown protocol %s' % protocol) |
| 42 | |
| 43 | if "-" in ports: |
| 44 | (first, last) = ports.split("-") |
| 45 | first = int(first.strip()) |
| 46 | last = int(last.strip()) |
| 47 | portStr = "%d:%d" % (first, last) |
| 48 | elif ":" in ports: |
| 49 | (first, last) = ports.split(":") |
| 50 | first = int(first.strip()) |
| 51 | last = int(last.strip()) |
| 52 | portStr = "%d:%d" % (first, last) |
| 53 | else: |
| 54 | portStr = "%d" % int(ports) |
| 55 | |
| 56 | nats.append( {"l4_protocol": protocol, "l4_port": portStr} ) |
| 57 | |
| 58 | return nats |
| 59 | |
| 60 | def ValidateNatList(ports): |
| 61 | try: |
| 62 | ParseNatList(ports) |
| 63 | except Exception,e: |
| 64 | raise ValidationError(str(e)) |
| 65 | |
Scott Baker | 58a9c7a | 2013-07-29 15:43:07 -0700 | [diff] [blame] | 66 | class NetworkTemplate(PlCoreBase): |
| 67 | VISIBILITY_CHOICES = (('public', 'public'), ('private', 'private')) |
Scott Baker | 87e5e09 | 2013-08-07 18:58:10 -0700 | [diff] [blame] | 68 | TRANSLATION_CHOICES = (('none', 'none'), ('NAT', 'NAT')) |
Scott Baker | f2e0cfc | 2014-11-17 16:03:49 -0800 | [diff] [blame] | 69 | TOPOLOGY_CHOICES = (('bigswitch', 'BigSwitch'), ('physical', 'Physical'), ('custom', 'Custom')) |
| 70 | CONTROLLER_CHOICES = ((None, 'None'), ('onos', 'ONOS'), ('custom', 'Custom')) |
Scott Baker | 58a9c7a | 2013-07-29 15:43:07 -0700 | [diff] [blame] | 71 | |
| 72 | name = models.CharField(max_length=32) |
| 73 | description = models.CharField(max_length=1024, blank=True, null=True) |
Scott Baker | 81fa17f | 2015-01-03 12:03:38 -0800 | [diff] [blame] | 74 | guaranteed_bandwidth = models.IntegerField(default=0) |
Scott Baker | 58a9c7a | 2013-07-29 15:43:07 -0700 | [diff] [blame] | 75 | visibility = models.CharField(max_length=30, choices=VISIBILITY_CHOICES, default="private") |
Scott Baker | 87e5e09 | 2013-08-07 18:58:10 -0700 | [diff] [blame] | 76 | translation = models.CharField(max_length=30, choices=TRANSLATION_CHOICES, default="none") |
Scott Baker | 81fa17f | 2015-01-03 12:03:38 -0800 | [diff] [blame] | 77 | shared_network_name = models.CharField(max_length=30, blank=True, null=True) |
| 78 | shared_network_id = models.CharField(null=True, blank=True, max_length=256, help_text="Quantum network") |
| 79 | topology_kind = models.CharField(null=False, blank=False, max_length=30, choices=TOPOLOGY_CHOICES, default="BigSwitch") |
| 80 | controller_kind = models.CharField(null=True, blank=True, max_length=30, choices=CONTROLLER_CHOICES, default=None) |
Scott Baker | 58a9c7a | 2013-07-29 15:43:07 -0700 | [diff] [blame] | 81 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 82 | def __init__(self, *args, **kwargs): |
| 83 | super(NetworkTemplate, self).__init__(*args, **kwargs) |
| 84 | |
| 85 | # somehow these got set wrong inside of the live database. Remove this |
| 86 | # code after all is well... |
Scott Baker | 81fa17f | 2015-01-03 12:03:38 -0800 | [diff] [blame] | 87 | if (self.topology_kind=="BigSwitch"): |
Scott Baker | bf7bc4a | 2015-01-06 15:11:29 -0800 | [diff] [blame] | 88 | print >> sys.stderr, "XXX warning: topology_kind invalid case" |
Scott Baker | 81fa17f | 2015-01-03 12:03:38 -0800 | [diff] [blame] | 89 | self.topology_kind="bigswitch" |
| 90 | elif (self.topology_kind=="Physical"): |
Scott Baker | bf7bc4a | 2015-01-06 15:11:29 -0800 | [diff] [blame] | 91 | print >> sys.stderr, "XXX warning: topology_kind invalid case" |
Scott Baker | 81fa17f | 2015-01-03 12:03:38 -0800 | [diff] [blame] | 92 | self.topology_kind="physical" |
| 93 | elif (self.topology_kind=="Custom"): |
Scott Baker | bf7bc4a | 2015-01-06 15:11:29 -0800 | [diff] [blame] | 94 | print >> sys.stderr, "XXX warning: topology_kind invalid case" |
Scott Baker | 81fa17f | 2015-01-03 12:03:38 -0800 | [diff] [blame] | 95 | self.toplogy_kind="custom" |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 96 | |
Scott Baker | 58a9c7a | 2013-07-29 15:43:07 -0700 | [diff] [blame] | 97 | def __unicode__(self): return u'%s' % (self.name) |
| 98 | |
| 99 | class Network(PlCoreBase): |
| 100 | name = models.CharField(max_length=32) |
| 101 | template = models.ForeignKey(NetworkTemplate) |
| 102 | subnet = models.CharField(max_length=32, blank=True) |
Scott Baker | 198fda1 | 2014-10-17 16:22:20 -0700 | [diff] [blame] | 103 | ports = models.CharField(max_length=1024, blank=True, null=True, validators=[ValidateNatList]) |
Scott Baker | 58a9c7a | 2013-07-29 15:43:07 -0700 | [diff] [blame] | 104 | labels = models.CharField(max_length=1024, blank=True, null=True) |
Siobhan Tully | ce652d0 | 2013-10-08 21:52:35 -0400 | [diff] [blame] | 105 | owner = models.ForeignKey(Slice, related_name="ownedNetworks", help_text="Slice that owns control of this Network") |
Scott Baker | 58a9c7a | 2013-07-29 15:43:07 -0700 | [diff] [blame] | 106 | |
Scott Baker | 0451fb6 | 2015-01-03 12:29:29 -0800 | [diff] [blame] | 107 | guaranteed_bandwidth = models.IntegerField(default=0) |
| 108 | permit_all_slices = models.BooleanField(default=False) |
| 109 | permitted_slices = models.ManyToManyField(Slice, blank=True, related_name="availableNetworks") |
Scott Baker | 87191e7 | 2013-08-06 08:55:07 -0700 | [diff] [blame] | 110 | slices = models.ManyToManyField(Slice, blank=True, related_name="networks", through="NetworkSlice") |
Scott Baker | 58a9c7a | 2013-07-29 15:43:07 -0700 | [diff] [blame] | 111 | slivers = models.ManyToManyField(Sliver, blank=True, related_name="networks", through="NetworkSliver") |
| 112 | |
Scott Baker | 0451fb6 | 2015-01-03 12:29:29 -0800 | [diff] [blame] | 113 | topology_parameters = models.TextField(null=True, blank=True) |
| 114 | controller_url = models.CharField(null=True, blank=True, max_length=1024) |
| 115 | controller_parameters = models.TextField(null=True, blank=True) |
Scott Baker | f2e0cfc | 2014-11-17 16:03:49 -0800 | [diff] [blame] | 116 | |
Scott Baker | 87191e7 | 2013-08-06 08:55:07 -0700 | [diff] [blame] | 117 | # for observer/manager |
| 118 | network_id = models.CharField(null=True, blank=True, max_length=256, help_text="Quantum network") |
| 119 | router_id = models.CharField(null=True, blank=True, max_length=256, help_text="Quantum router id") |
| 120 | subnet_id = models.CharField(null=True, blank=True, max_length=256, help_text="Quantum subnet id") |
| 121 | |
Scott Baker | 58a9c7a | 2013-07-29 15:43:07 -0700 | [diff] [blame] | 122 | def __unicode__(self): return u'%s' % (self.name) |
| 123 | |
| 124 | def save(self, *args, **kwds): |
| 125 | if (not self.subnet) and (NO_OBSERVER): |
| 126 | from util.network_subnet_allocator import find_unused_subnet |
| 127 | self.subnet = find_unused_subnet(existing_subnets=[x.subnet for x in Network.objects.all()]) |
| 128 | super(Network, self).save(*args, **kwds) |
| 129 | |
Tony Mack | 5b06147 | 2014-02-04 07:57:10 -0500 | [diff] [blame] | 130 | def can_update(self, user): |
Tony Mack | 5ff90fc | 2015-02-08 21:38:41 -0500 | [diff] [blame] | 131 | return user.can_update_slice(self.owner) |
Tony Mack | 5b06147 | 2014-02-04 07:57:10 -0500 | [diff] [blame] | 132 | |
Scott Baker | 5bbaa23 | 2014-08-14 17:23:15 -0700 | [diff] [blame] | 133 | @property |
| 134 | def nat_list(self): |
Scott Baker | 198fda1 | 2014-10-17 16:22:20 -0700 | [diff] [blame] | 135 | return ParseNatList(self.ports) |
Scott Baker | 5bbaa23 | 2014-08-14 17:23:15 -0700 | [diff] [blame] | 136 | |
Tony Mack | 5b06147 | 2014-02-04 07:57:10 -0500 | [diff] [blame] | 137 | @staticmethod |
| 138 | def select_by_user(user): |
| 139 | if user.is_admin: |
| 140 | qs = Network.objects.all() |
| 141 | else: |
Tony Mack | 5efa133 | 2014-04-02 15:45:48 -0400 | [diff] [blame] | 142 | slices = Slice.select_by_user(user) |
| 143 | #slice_ids = [s.id for s in Slice.select_by_user(user)] |
| 144 | qs = Network.objects.filter(owner__in=slices) |
Tony Mack | 5b06147 | 2014-02-04 07:57:10 -0500 | [diff] [blame] | 145 | return qs |
| 146 | |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 147 | class ControllerNetwork(PlCoreBase): |
Tony Mack | f3bbe47 | 2014-11-30 15:33:35 -0500 | [diff] [blame] | 148 | objects = ControllerLinkManager() |
| 149 | deleted_objects = ControllerLinkDeletionManager() |
Sapan Bhatia | 6df5651 | 2014-09-22 14:52:59 -0400 | [diff] [blame] | 150 | |
Tony Mack | f3bbe47 | 2014-11-30 15:33:35 -0500 | [diff] [blame] | 151 | # Stores the openstack ids at various controllers |
| 152 | network = models.ForeignKey(Network, related_name='controllernetworks') |
| 153 | controller = models.ForeignKey(Controller, related_name='controllernetworks') |
Tony Mack | 457c84c | 2014-04-08 16:37:56 -0400 | [diff] [blame] | 154 | net_id = models.CharField(null=True, blank=True, max_length=256, help_text="Quantum network") |
Tony Mack | e9b0869 | 2014-04-07 19:38:28 -0400 | [diff] [blame] | 155 | router_id = models.CharField(null=True, blank=True, max_length=256, help_text="Quantum router id") |
Scott Baker | 95d81c7 | 2014-08-12 18:29:27 -0700 | [diff] [blame] | 156 | subnet_id = models.CharField(null=True, blank=True, max_length=256, help_text="Quantum subnet id") |
| 157 | subnet = models.CharField(max_length=32, blank=True) |
Tony Mack | 549f7b1 | 2015-04-11 12:17:59 -0400 | [diff] [blame] | 158 | |
| 159 | class Meta: |
| 160 | unique_together = ('network', 'controller') |
Tony Mack | a4736f5 | 2015-03-09 17:13:14 -0400 | [diff] [blame] | 161 | |
Tony Mack | e9b0869 | 2014-04-07 19:38:28 -0400 | [diff] [blame] | 162 | @staticmethod |
| 163 | def select_by_user(user): |
| 164 | if user.is_admin: |
Scott Baker | 0da79c5 | 2015-02-23 17:22:33 -0800 | [diff] [blame] | 165 | qs = ControllerNetwork.objects.all() |
Tony Mack | e9b0869 | 2014-04-07 19:38:28 -0400 | [diff] [blame] | 166 | else: |
| 167 | slices = Slice.select_by_user(user) |
| 168 | networks = Network.objects.filter(owner__in=slices) |
Scott Baker | 0da79c5 | 2015-02-23 17:22:33 -0800 | [diff] [blame] | 169 | qs = ControllerNetwork.objects.filter(network__in=networks) |
Scott Baker | 95d81c7 | 2014-08-12 18:29:27 -0700 | [diff] [blame] | 170 | return qs |
Tony Mack | e9b0869 | 2014-04-07 19:38:28 -0400 | [diff] [blame] | 171 | |
Scott Baker | 87191e7 | 2013-08-06 08:55:07 -0700 | [diff] [blame] | 172 | class NetworkSlice(PlCoreBase): |
| 173 | # This object exists solely so we can implement the permission check when |
| 174 | # adding slices to networks. It adds no additional fields to the relation. |
| 175 | |
Sapan Bhatia | 13d2db9 | 2014-11-11 21:47:45 -0500 | [diff] [blame] | 176 | network = models.ForeignKey(Network,related_name='networkslices') |
| 177 | slice = models.ForeignKey(Slice,related_name='networkslices') |
Scott Baker | 87191e7 | 2013-08-06 08:55:07 -0700 | [diff] [blame] | 178 | |
Tony Mack | 549f7b1 | 2015-04-11 12:17:59 -0400 | [diff] [blame] | 179 | class Meta: |
| 180 | unique_together = ('network', 'slice') |
Tony Mack | a4736f5 | 2015-03-09 17:13:14 -0400 | [diff] [blame] | 181 | |
Scott Baker | 87191e7 | 2013-08-06 08:55:07 -0700 | [diff] [blame] | 182 | def save(self, *args, **kwds): |
| 183 | slice = self.slice |
Scott Baker | f1b474b | 2015-04-13 17:23:28 -0700 | [diff] [blame] | 184 | if (slice not in self.network.permitted_slices.all()) and (slice != self.network.owner) and (not self.network.permit_all_slices): |
Scott Baker | 87191e7 | 2013-08-06 08:55:07 -0700 | [diff] [blame] | 185 | # to add a sliver to the network, then one of the following must be true: |
| 186 | # 1) sliver's slice is in network's permittedSlices list, |
| 187 | # 2) sliver's slice is network's owner, or |
| 188 | # 3) network's permitAllSlices is true |
| 189 | raise ValueError("Slice %s is not allowed to connect to network %s" % (str(slice), str(self.network))) |
| 190 | |
| 191 | super(NetworkSlice, self).save(*args, **kwds) |
| 192 | |
| 193 | def __unicode__(self): return u'%s-%s' % (self.network.name, self.slice.name) |
| 194 | |
Tony Mack | 5b06147 | 2014-02-04 07:57:10 -0500 | [diff] [blame] | 195 | def can_update(self, user): |
Tony Mack | 5ff90fc | 2015-02-08 21:38:41 -0500 | [diff] [blame] | 196 | return user.can_update_slice(self.slice) |
Tony Mack | 5b06147 | 2014-02-04 07:57:10 -0500 | [diff] [blame] | 197 | |
Tony Mack | 5b06147 | 2014-02-04 07:57:10 -0500 | [diff] [blame] | 198 | @staticmethod |
| 199 | def select_by_user(user): |
| 200 | if user.is_admin: |
| 201 | qs = NetworkSlice.objects.all() |
| 202 | else: |
| 203 | slice_ids = [s.id for s in Slice.select_by_user(user)] |
| 204 | qs = NetworkSlice.objects.filter(id__in=slice_ids) |
| 205 | return qs |
| 206 | |
Scott Baker | 58a9c7a | 2013-07-29 15:43:07 -0700 | [diff] [blame] | 207 | class NetworkSliver(PlCoreBase): |
Sapan Bhatia | ab9f84b | 2014-11-11 22:01:30 -0500 | [diff] [blame] | 208 | network = models.ForeignKey(Network,related_name='networkslivers') |
Scott Baker | deb5f7b | 2015-08-18 17:04:01 -0700 | [diff] [blame^] | 209 | sliver = models.ForeignKey(Sliver, null=True, blank=True, related_name='networkslivers') |
Scott Baker | 026bfe7 | 2013-07-29 16:03:50 -0700 | [diff] [blame] | 210 | ip = models.GenericIPAddressField(help_text="Sliver ip address", blank=True, null=True) |
Scott Baker | f4df952 | 2013-08-19 17:56:45 -0700 | [diff] [blame] | 211 | port_id = models.CharField(null=True, blank=True, max_length=256, help_text="Quantum port id") |
Scott Baker | deb5f7b | 2015-08-18 17:04:01 -0700 | [diff] [blame^] | 212 | reserve = models.BooleanField(default=False, help_text="Reserve this port for future use") |
Scott Baker | 58a9c7a | 2013-07-29 15:43:07 -0700 | [diff] [blame] | 213 | |
Tony Mack | 549f7b1 | 2015-04-11 12:17:59 -0400 | [diff] [blame] | 214 | class Meta: |
| 215 | unique_together = ('network', 'sliver') |
Tony Mack | a4736f5 | 2015-03-09 17:13:14 -0400 | [diff] [blame] | 216 | |
Scott Baker | 58a9c7a | 2013-07-29 15:43:07 -0700 | [diff] [blame] | 217 | def save(self, *args, **kwds): |
Scott Baker | deb5f7b | 2015-08-18 17:04:01 -0700 | [diff] [blame^] | 218 | if self.sliver: |
| 219 | slice = self.sliver.slice |
| 220 | if (slice not in self.network.permitted_slices.all()) and (slice != self.network.owner) and (not self.network.permit_all_slices): |
| 221 | # to add a sliver to the network, then one of the following must be true: |
| 222 | # 1) sliver's slice is in network's permittedSlices list, |
| 223 | # 2) sliver's slice is network's owner, or |
| 224 | # 3) network's permitAllSlices is true |
| 225 | raise ValueError("Slice %s is not allowed to connect to network %s" % (str(slice), str(self.network))) |
| 226 | |
| 227 | if (not self.sliver) and (not self.reserve): |
| 228 | raise ValueError("If NetworkSliver.sliver is false, then NetworkSliver.reserved must be set to True") |
Scott Baker | 87191e7 | 2013-08-06 08:55:07 -0700 | [diff] [blame] | 229 | |
Scott Baker | 58a9c7a | 2013-07-29 15:43:07 -0700 | [diff] [blame] | 230 | if (not self.ip) and (NO_OBSERVER): |
| 231 | from util.network_subnet_allocator import find_unused_address |
| 232 | self.ip = find_unused_address(self.network.subnet, |
| 233 | [x.ip for x in self.network.networksliver_set.all()]) |
| 234 | super(NetworkSliver, self).save(*args, **kwds) |
| 235 | |
Scott Baker | deb5f7b | 2015-08-18 17:04:01 -0700 | [diff] [blame^] | 236 | def __unicode__(self): |
| 237 | if self.sliver: |
| 238 | return u'%s-%s' % (self.network.name, self.sliver.instance_name) |
| 239 | else: |
| 240 | return u'%s-reserved-%s' % (self.network.name, self.id) |
Scott Baker | 58a9c7a | 2013-07-29 15:43:07 -0700 | [diff] [blame] | 241 | |
Tony Mack | 5b06147 | 2014-02-04 07:57:10 -0500 | [diff] [blame] | 242 | def can_update(self, user): |
Scott Baker | deb5f7b | 2015-08-18 17:04:01 -0700 | [diff] [blame^] | 243 | if self.sliver: |
| 244 | return user.can_update_slice(self.sliver.slice) |
| 245 | if self.network: |
| 246 | return user.can_update_slice(self.network.owner) |
| 247 | return False |
Tony Mack | 5b06147 | 2014-02-04 07:57:10 -0500 | [diff] [blame] | 248 | |
Tony Mack | 5b06147 | 2014-02-04 07:57:10 -0500 | [diff] [blame] | 249 | @staticmethod |
| 250 | def select_by_user(user): |
| 251 | if user.is_admin: |
| 252 | qs = NetworkSliver.objects.all() |
| 253 | else: |
| 254 | sliver_ids = [s.id for s in NetworkSliver.select_by_user(user)] |
| 255 | qs = NetworkSliver.objects.filter(id__in=sliver_ids) |
| 256 | return qs |
| 257 | |
Scott Baker | 58a9c7a | 2013-07-29 15:43:07 -0700 | [diff] [blame] | 258 | class Router(PlCoreBase): |
| 259 | name = models.CharField(max_length=32) |
| 260 | owner = models.ForeignKey(Slice, related_name="routers") |
| 261 | permittedNetworks = models.ManyToManyField(Network, blank=True, related_name="availableRouters") |
| 262 | networks = models.ManyToManyField(Network, blank=True, related_name="routers") |
| 263 | |
| 264 | def __unicode__(self): return u'%s' % (self.name) |
| 265 | |
Tony Mack | 5ff90fc | 2015-02-08 21:38:41 -0500 | [diff] [blame] | 266 | def can_update(self, user): |
| 267 | return user.can_update_slice(self.owner) |
| 268 | |
Scott Baker | 58a9c7a | 2013-07-29 15:43:07 -0700 | [diff] [blame] | 269 | class NetworkParameterType(PlCoreBase): |
| 270 | name = models.SlugField(help_text="The name of this parameter", max_length=128) |
| 271 | description = models.CharField(max_length=1024) |
| 272 | |
| 273 | def __unicode__(self): return u'%s' % (self.name) |
| 274 | |
| 275 | class NetworkParameter(PlCoreBase): |
Sapan Bhatia | 13d2db9 | 2014-11-11 21:47:45 -0500 | [diff] [blame] | 276 | parameter = models.ForeignKey(NetworkParameterType, related_name="networkparameters", help_text="The type of the parameter") |
Scott Baker | 58a9c7a | 2013-07-29 15:43:07 -0700 | [diff] [blame] | 277 | value = models.CharField(help_text="The value of this parameter", max_length=1024) |
| 278 | |
| 279 | # The required fields to do a ObjectType lookup, and object_id assignment |
| 280 | content_type = models.ForeignKey(ContentType) |
| 281 | object_id = models.PositiveIntegerField() |
| 282 | content_object = generic.GenericForeignKey('content_type', 'object_id') |
| 283 | |
| 284 | def __unicode__(self): |
| 285 | return self.parameter.name |
| 286 | |
| 287 | |