source: django_apps/wndb/models.py

Last change on this file was 340, checked in by Rick van der Zwet, 13 years ago

Initial idea of Wireless Nodes DataBase.

File size: 1.7 KB
Line 
1from django.db import models
2from django.db.models import Q
3
4# Create your models here.
5
6MODE_CHOICES = (
7 ('master', 'master'),
8 ('managed','managed'),
9)
10
11PORT_CHOICES = (
12 ('vr0','vr0'),
13 ('vr1','vr1'),
14 ('vr2','vr2'),
15 ('ue0','ue0'),
16 ('ue1','ue1'),
17 ('sis0','sis0'),
18 ('sis1','sis1'),
19)
20
21MODEL_CHOICES = (
22 ('Ethernet', 'Ethernet'),
23 ('Bullet2', 'NanoStation2'),
24 ('NanoStation2', 'NanoStation2'),
25 ('NanoStationM2', 'NanoStationM2'),
26 ('NanoStation5', 'NanoStation5'),
27 ('NanoStationM5', 'NanoStationM5'),
28)
29
30NETMASK_CHOICES = zip(range(12,31),range(12,31))
31class IPBlock(models.Model):
32 network = models.IPAddressField(default="172.16.",unique=True)
33 netmask = models.IntegerField(choices=NETMASK_CHOICES,default=29)
34 def __unicode__(self):
35 return "%s/%s" % (self.network, self.netmask)
36
37DEFAULT_IPBLOCK = lambda: IPBlock.objects.get_or_create(network='0.0.0.0',netmask=0)[0].id
38
39class Node(models.Model):
40 name = models.CharField(max_length="100")
41 def __unicode__(self):
42 return self.name
43
44
45class Interface(models.Model):
46 node = models.ForeignKey(Node)
47 port = models.CharField(max_length="100", choices=PORT_CHOICES, default="vr0")
48 model = models.CharField(max_length="100", choices=MODEL_CHOICES, default="Ethernet")
49 mode = models.CharField(max_length="100", choices=MODE_CHOICES, default="master")
50 def __unicode__(self):
51 return "%s - %s - %s - %s" % (self.node, self.port, self.model, self.mode)
52
53class Link(models.Model):
54 ip_block = models.ForeignKey(IPBlock,unique=True,default=DEFAULT_IPBLOCK)
55 interfaces = models.ManyToManyField(Interface)
56 def __unicode__(self):
57 return "%s : %s" % (self.ip_block, '|'.join(map(str,self.interfaces.all())))
58
59
Note: See TracBrowser for help on using the repository browser.