Changeset 6231


Ignore:
Timestamp:
Aug 23, 2008, 12:44:18 PM (16 years ago)
Author:
roland
Message:

added basic addinterlink functionality

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TODO

    r6230 r6231  
    1414        views.py and the templates. See:
    1515        http://www.djangoproject.com/documentation/url_dispatch/#reverse
     16* remove hardcoding in wllogic.py for 172.17 and higher as master ip
    1617* Interface cleanups:
    1718** option to edit/delete fields
  • exodus/views.py

    r6230 r6231  
    99
    1010from exodus.models import *
    11 from exodus.wllogic import freemasterip, newSSIDName
     11from exodus.wllogic import freemasterip, newSSIDName, freeinterlinkip
    1212
    1313class AddLocationForm(forms.ModelForm):
     
    8383                                        print '''these ifaces are of the same type'''
    8484                                        instance.same=True
    85                                         print instance.same
    86 
    87                                 if str(instance.iface1.type) == '11b' or str(instance.iface1.type) == '11g':
    88                                         print '''it's 11b or g'''
    89 
    90                                 #if (instance.iface1.type == '11b' | instance.iface2.type == '11b' )  &
    91                                 #               (instance.iface1.type == '11g' || instance.iface2.type == '11g'):
    92                                 #               print '''11b and 11g are compatible'''
     85                                if str(instance.iface1.type) == '11b' and str(instance.iface2.type) == '11g':
     86                                        instance.same=True
     87                                        print '11b + 11g'
     88                                if str(instance.iface1.type) == '11g' and str(instance.iface2.type) == '11b':
     89                                        instance.same=True
     90                                        print '11g + 11b'
     91                                #Generate IP addresses
     92                                if instance.same == True:
     93                                        instance.ip1,instance.ip2 = freeinterlinkip()
     94                                        netmask = '30'
     95                                        instance.save()
     96                                       
    9397                        #if wifi: check master and managed states for existings NICs/Interlinks
    9498                                #Generate SSID
     99                        # add descriptions
    95100                        #Generate ips and netmask
    96101                        #Save form
  • exodus/wllogic.py

    r6229 r6231  
    11# (c) Roland van Laar
    22
    3 from exodus.models import Node, Network
     3from exodus.models import Node, Network, Interlink
    44
    55def newSSIDName(node, nic, desc):
     
    3939   
    4040        return showaddr(i)
     41
     42def freeinterlinkip():
     43        taken = {}
     44       
     45        #add all interlink ipaddresses in taken[]
     46        for link in Interlink.objects.all():
     47                addr = parseaddr(link.ip1)
     48                taken[addr] = 1
     49                addr = parseaddr(link.ip2)
     50                taken[addr] = 1
     51       
     52        size = 30
     53        numaddrs = 1 << (32 -size)
     54        i = 0xAC100001L
     55        while taken.has_key(i):
     56                print showaddr(i)
     57                i = i + numaddrs
     58        ips = [showaddr(i), showaddr(i+1)]     
     59        return ips
Note: See TracChangeset for help on using the changeset viewer.