Changeset 6313


Ignore:
Timestamp:
Sep 23, 2008, 11:40:09 PM (17 years ago)
Author:
RIck van der Zwet
Message:
  • trunk/Makefile new command was missing it comment, leaving it out of the make help output
  • trunk/exodus/templates/node-detail.html IP details for information only, more generic linking
  • trunk/exodus/views.py, trunk/exodus/wllogic.py: First attempt to get automatic IP assignment working, yet without boundries and for example checks of non changed interface commits
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/Makefile

    r6311 r6313  
    2727
    2828new: dist-clean init debug-init debug
     29#Fresh start, with new datebase which include debugging code
  • TabularUnified trunk/exodus/templates/node-detail.html

    r6288 r6313  
    22
    33{% block content %}
     4<a href="{% url nodelist %}">Node List</a>
    45
    56<div style="border:1px solid #000000;">
     
    2122        <div style="border:1px solid #000000;">
    2223        <h3>iface: {{ nic.iface }} </h3>
    23         status: {{ nic.status }} <br>
    2424        type: {{ nic.type }} <br>
    2525        description: {{ nic.shortdesc }} <br>
     26        IP: {{ nic.ip }}/{{ nic.netmask }}<br />
    2627       
    2728        {% ifnotequal nic.type "eth" %}
     
    4344                <li>Long description: {{ interlink.desc }} </li>
    4445                <li>IP: {{ interlink.ip }}/{{ interlink.netmask }} </li>
    45                 <li> Link to Node: <a href=../../{{ interlink.node }}/node/>
     46                <li> Link to Node: <a href="{% url node-detail interlink.node %}">
    4647                        {{ interlink.node }}</a> </li>
    4748                </ul>
  • TabularUnified trunk/exodus/views.py

    r6312 r6313  
    1111
    1212from exodus.models import *
    13 from exodus.wllogic import freeMasterIP, newSSIDName, freeinterlinkip
     13from exodus.wllogic import freeMasterIP, newSSIDName, addInterlinkIP, freeInterlinkIP
    1414
    1515class AddLocationForm(forms.ModelForm):
     
    8686
    8787def saveInterface(form):
     88        #XXX: Should have checking wether form has actually been changed to avoid creation of IPs every time
    8889        instance  = form.save(commit=False)
    8990        if str(instance.type) != "eth":
     
    9192                instance.channel = '1'
    9293                instance.mode = 1 # set to master
    93         if instance.link == None:
     94        if not instance.link:
     95                instance.ip = freeInterlinkIP(instance)
     96        else:
     97                instance.ip = addInterlinkIP(instance.link)
     98        instance.save()
     99        #Dirty to hack to get reference to self working
     100        if not instance.link:
    94101                instance.link = instance
    95         #XXX: Needs to be dynamic, using some logic
    96         instance.ip = '172.16.0.1'
    97         instance.save()
     102                instance.save()
    98103
    99104def addInterface(request):
  • TabularUnified trunk/exodus/wllogic.py

    r6312 r6313  
    11# (c) Roland van Laar
    22
    3 from exodus.models import Node, Network
     3from exodus.models import Node, Interface
    44
    55def newSSIDName(node, nic, desc):
     
    4545        return(showaddr(broadcast(address,netmask)))
    4646
     47#XXX: freeMasterIP/addInterlinkIP should be more general by writing a function
     48#     with finds a range based on a given range, taken ip/netmask and requested subnet
     49
    4750def freeMasterIP(node):
    4851        taken = {}
    4952
    5053        for node in Node.objects.all():
    51                 addr = parseaddr(node.masterip)
     54                addr = network(node.masterip,24)
    5255                taken[addr] = 1
    5356
     
    6366        return showaddr(i)
    6467
    65 def freeinterlinkip():
     68def freeInterlinkIP(masterLink):
    6669        taken = {}
    6770       
    68         #add all interlink ipaddresses in taken[]
    69         for link in Interlink.objects.all():
    70                 addr = parseaddr(link.ip1)
     71        for interface in Interface.objects.filter(node=masterLink.node):
     72                #Grr, needs all interfaces which are master requires a bit of a hack
     73                addr = network(interface.ip, interface.netmask)
    7174                taken[addr] = 1
    72                 addr = parseaddr(link.ip2)
     75
     76        #Should be dynamic based on the number of hosts in here
     77        size = masterLink.netmask
     78        numaddrs = 1 << (32 - size)
     79        i = network(masterLink.node.masterip,24) + 4
     80        while taken.has_key(i):
     81                i = i + numaddrs
     82       
     83        return showaddr(i)
     84
     85def addInterlinkIP(masterLink):
     86        taken = {}
     87       
     88        for interface in Interface.objects.filter(link=masterLink):
     89                #Grr, needs all interfaces which are master requires a bit of a hack
     90                addr = parseaddr(interface.ip)
    7391                taken[addr] = 1
     92
     93        size = 32
     94        numaddrs = 1 << (32 - size)
     95        i = network(masterLink.ip, masterLink.netmask) + 1
     96        while taken.has_key(i):
     97                i = i + 1
    7498       
    75         size = 30
    76         numaddrs = 1 << (32 -size)
    77         i = 0xAC100001L
    78         while taken.has_key(i):
    79                 print showaddr(i)
    80                 i = i + numaddrs
    81         ips = [showaddr(i), showaddr(i+1)]     
    82         return ips
     99        return showaddr(i)
Note: See TracChangeset for help on using the changeset viewer.