Changeset 6253


Ignore:
Timestamp:
Sep 8, 2008, 11:28:41 PM (16 years ago)
Author:
roland
Message:

Reworked database model.
According to discussion-08-09-2008.txt

Files:
4 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • doc/discussion-08-09-2008.txt

    r6252 r6253  
    4949- Nic -*> Link -> PublicAP
    5050- Choice ssid/channel PublicAP precedence
    51 - Link needed due desc,status,ip,etc
     51- Link needed due desc,ip,etc
    5252- LinkPool, linkID to Link to indentify master
    5353
  • exodus/models.py

    r6234 r6253  
    66# Create your models here.
    77
    8 class NICType(models.Model):
    9     type = models.CharField(max_length=10)
     8#No need to formalize it; CHOICES don't change much
    109
    11     def __str__(self):
    12         return self.type
     10STATUS_CHOICES = (
     11                        ('up', 'up'),
     12                        ('dw', 'down'),
     13                        ('pl', 'planned'),
     14                        )
    1315
    14 class Polar(models.Model):
    15     polar = models.CharField(max_length=10)
    16    
    17     def __str__(self):
    18         return self.polar
     16POLAR_CHOICES = (
     17                        ('hr', 'horizontal'),
     18                        ('vr', 'vertical'),
     19                        )
    1920
    20 class Status(models.Model):
    21     status = models.CharField(max_length=200)
    22    
    23     def __str__(self):
    24         return self.status
    25 
    26 class Mode(models.Model):
    27     mode = models.CharField(max_length=10)
    28 
    29     class Meta:
    30         verbose_name = "wifi mode"
    31 
    32     def __str__(self):
    33         return self.mode
     21INTERFACE_TYPE_CHOICES = (
     22                        ('eth', 'eth'),
     23                        ('11a', '11a'),
     24                        ('11b', '11b'),
     25                        ('11g', '11g'),
     26                        )
     27WIFI_MODE_CHOICES = (
     28                        ('ms', 'master'),
     29                        ('mn', 'managed'),
     30                        )
    3431
    3532class Antenna(models.Model):
     
    4946
    5047
    51 class Network(models.Model):
    52     domainname = models.CharField(max_length=50)
    53     ipspacestart = models.IPAddressField()
    54     netmask = models.IntegerField()
    55 
    56     def __str__(self):
    57         return self.domainname
    58 
    5948class DnsServer(models.Model):
    6049        ipaddress = models.IPAddressField( unique=True)
    61         domainname = models.ForeignKey(Network)
     50        domainname = models.CharField(max_length=50)
    6251
    6352        def __str__(self):
    6453                return self.ipaddress
    6554
     55class Network(models.Model):
     56        ipspacestart = models.IPAddressField()
     57        netmask = models.IntegerField()
     58        dnsserver = models.ForeignKey(DnsServer)
     59
     60        def __str__(self):
     61                return self.domainname
     62
     63
    6664class Node(models.Model):
    6765    name = models.CharField(max_length=30, unique=True)
    6866    location = models.ForeignKey(Location)
    69     status = models.ForeignKey(Status,default=1)
     67    status = models.CharField(max_length=10, choices=STATUS_CHOICES)
    7068    masterip = models.IPAddressField()
    7169    network = models.ForeignKey(Network,default=1)
     
    7775        return self.name
    7876
    79 class NIC(models.Model):
    80     node = models.ForeignKey(Node)
    81     iface = models.CharField(max_length=10,verbose_name="interface")
    82     polar = models.ForeignKey(Polar, blank=True, null=True,
    83               verbose_name="polarisation")
    84     ssid = models.CharField(max_length=30, blank=True, null=True)
    85     mode = models.ForeignKey(Mode, blank=True, null=True)
    86     status = models.ForeignKey(Status, default=1)
    87     channel = models.IntegerField(blank=True, null=True)
    88     antenna = models.ForeignKey(Antenna, blank=True, null=True)
    89     type = models.ForeignKey(NICType)
     77class LinkPool(models.Model):
     78        netmask = models.IntegerField(default=30)
    9079
    91     def __str__(self):
    92         return "%s, %s" % (self.node.name, self.iface)
     80class Link(models.Model):
     81        ip = models.IPAddressField()
     82        shortdesc = models.CharField(max_length=10)
     83        desc = models.CharField(max_length=100)
     84        linkpool = models.ForeignKey(LinkPool)
    9385
    94 class Interlink(models.Model):
    95     status = models.ForeignKey(Status,default=1)
    96     netmask = models.IntegerField(default=30)
    97     iface1 = models.ForeignKey(NIC,related_name='link1')
    98     ip1 = models.IPAddressField()
    99     iface2 = models.ForeignKey(NIC,related_name='link2')
    100     ip2 = models.IPAddressField()
    101     shortdesc1 = models.CharField(max_length=10)
    102     shortdesc2 = models.CharField(max_length=10)
    103     desc1 = models.CharField(max_length=100)
    104     desc2 = models.CharField(max_length=100)
     86        def __str__(self):
     87                return "%s" % (self.shortdesc)
    10588
    106     def __str__(self):
    107         return "%s to %s" %(self.iface1, self.iface2)
     89class Interface(models.Model):
     90        node = models.ForeignKey(Node)
     91        iface = models.CharField(max_length=10, verbose_name="interface")
     92        polar = models.CharField(max_length=10, choices=POLAR_CHOICES)
     93        ssid = models.CharField(max_length=30, blank=True, null=True)
     94        mode = models.CharField(max_length=10, choices=WIFI_MODE_CHOICES)
     95        channel = models.IntegerField(blank=True, null=True)
     96        antenna = models.ForeignKey(Antenna, blank=True, null=True)
     97        type = models.CharField(max_length=10, choices=INTERFACE_TYPE_CHOICES)
     98        links = models.ManyToManyField(Link)
     99       
     100        def __str__(self):
     101                return "%s:%s" % (self.node.name, self.iface)
    108102
    109 class Omni(models.Model):
    110     iface = models.ForeignKey(NIC,related_name='omni')
    111     status = models.ForeignKey(Status,default=1)
     103
     104       
     105class PublicAP(models.Model):
     106    iface = models.ForeignKey(Interface)
    112107    ip = models.IPAddressField()
    113108    netmask = models.IntegerField(default=30)
     
    118113
    119114    def __str__(self):
    120         return "%s %s" % (self.iface.node.name, self.shortdesc)
     115        return "%s" % (self.shortdesc)
    121116
    122117class DhcpStatic(models.Model):
     
    124119    macaddress = models.CharField(max_length=17)
    125120    address = models.IPAddressField()
    126     omni = models.ForeignKey(Omni)
     121    PublicAP = models.ForeignKey(PublicAP)
    127122
    128123    def __str__(self):
Note: See TracChangeset for help on using the changeset viewer.