Changeset 6313
- Timestamp:
- Sep 23, 2008, 11:40:09 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/Makefile ¶
r6311 r6313 27 27 28 28 new: 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 2 2 3 3 {% block content %} 4 <a href="{% url nodelist %}">Node List</a> 4 5 5 6 <div style="border:1px solid #000000;"> … … 21 22 <div style="border:1px solid #000000;"> 22 23 <h3>iface: {{ nic.iface }} </h3> 23 status: {{ nic.status }} <br>24 24 type: {{ nic.type }} <br> 25 25 description: {{ nic.shortdesc }} <br> 26 IP: {{ nic.ip }}/{{ nic.netmask }}<br /> 26 27 27 28 {% ifnotequal nic.type "eth" %} … … 43 44 <li>Long description: {{ interlink.desc }} </li> 44 45 <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 %}"> 46 47 {{ interlink.node }}</a> </li> 47 48 </ul> -
TabularUnified trunk/exodus/views.py ¶
r6312 r6313 11 11 12 12 from exodus.models import * 13 from exodus.wllogic import freeMasterIP, newSSIDName, freeinterlinkip13 from exodus.wllogic import freeMasterIP, newSSIDName, addInterlinkIP, freeInterlinkIP 14 14 15 15 class AddLocationForm(forms.ModelForm): … … 86 86 87 87 def saveInterface(form): 88 #XXX: Should have checking wether form has actually been changed to avoid creation of IPs every time 88 89 instance = form.save(commit=False) 89 90 if str(instance.type) != "eth": … … 91 92 instance.channel = '1' 92 93 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: 94 101 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() 98 103 99 104 def addInterface(request): -
TabularUnified trunk/exodus/wllogic.py ¶
r6312 r6313 1 1 # (c) Roland van Laar 2 2 3 from exodus.models import Node, Network3 from exodus.models import Node, Interface 4 4 5 5 def newSSIDName(node, nic, desc): … … 45 45 return(showaddr(broadcast(address,netmask))) 46 46 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 47 50 def freeMasterIP(node): 48 51 taken = {} 49 52 50 53 for node in Node.objects.all(): 51 addr = parseaddr(node.masterip)54 addr = network(node.masterip,24) 52 55 taken[addr] = 1 53 56 … … 63 66 return showaddr(i) 64 67 65 def free interlinkip():68 def freeInterlinkIP(masterLink): 66 69 taken = {} 67 70 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) 71 74 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 85 def 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) 73 91 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 74 98 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.