- Timestamp:
- Sep 29, 2008, 10:07:42 PM (16 years ago)
- Location:
- trunk/exodus
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/exodus/models.py
r6288 r6317 109 109 return "Alias %s" % (self.iface) 110 110 111 # 112 # XXX: Needs rethinking, dhcp[start|stop] could be removed if whole publicAP is 113 # going to be activated as DHCP range, or only number of fixed clients needs to 114 # be defined, all other could be calculated on the fly if needed 111 115 class PublicAP(models.Model): 112 iface = models.ForeignKey(Interface )116 iface = models.ForeignKey(Interface,related_name='ap') 113 117 ip = models.IPAddressField(unique=True) 114 netmask = models.IntegerField(default= 30)118 netmask = models.IntegerField(default=28) 115 119 dhcpstart = models.IPAddressField() 116 120 dhcpstop = models.IPAddressField() -
trunk/exodus/templates/addomni.html
r6206 r6317 2 2 3 3 {% block content %} 4 <h1>Add an Omni</h1>4 <h1>Add an public access point</h1> 5 5 6 6 <form method="post" action="."> -
trunk/exodus/templates/exodus-template.html
r6287 r6317 17 17 <A class="menu" href="{% url exodus.views.addLocation %}">Add Location</a><br> 18 18 <A class="menu" href="{% url exodus.views.addNode %}">Add Node</a><br> 19 <A class="menu" href="{% url exodus.views.addInterface %}">Add Interface</a><br>20 <A class="menu" href="{% url exodus.views.addPublicAP %}">Add PublicAP</a><br>21 <p>22 19 </td> 23 20 <td valign="top" class="right"> -
trunk/exodus/templates/node-detail.html
r6315 r6317 17 17 18 18 <h2>Interfaces</h2> 19 <a href="{% url exodus.views.addInterface %}?node={{ object.name }}">Add new interface</a> 19 <a href="{% url exodus.views.addInterface %}?node={{ object.name }}">Add new interface</a><p /> 20 20 21 21 {% for nic in object.interface_set.all %} 22 <p>23 22 <div style="border:1px solid #000000;"> 24 23 <h3>iface: {{ nic.iface }} </h3> 24 <a href="{% url exodus.views.addPublicAP %}?iface={{ nic }}">Add new public access point</a><p /> 25 25 type: {{ nic.type }} <br> 26 26 description: {{ nic.shortdesc }} <br> … … 35 35 {% endifnotequal %} 36 36 <a href="{% url exodus.views.editInterface nic %}">EDIT</a> 37 <a href="{% url exodus.views.delInterface nic %}">DELETE</a> 37 38 </div> 38 39 … … 51 52 {% endfor %} 52 53 53 54 {% for omni in nic.omni.all %} 55 <ul> 56 <li>DHCP {{ omni.dhcpstart }}-{{ omni.dhcpstop }}</li> 57 {% for dhcp in omni.dhcpstatic.all %} 54 <ul> 55 {% for accessPoint in nic.ap.all %} 56 <div style="border:1px solid #000000;"> 57 <p /> 58 <li>Public Access Point: {{ accessPoint.ip}}/{{accessPoint.netmask }} 59 {% for dhcp in accessPoint.dhcpstatic.all %} 58 60 <ul> 59 61 <li>Hostname: {{ dhcp.hostname }} </li> … … 61 63 </ul> 62 64 {% endfor %} 63 </ul> 65 </li> 66 <p /> 67 </div> 64 68 {% endfor %} 69 </ul> 65 70 {% endfor %} 66 71 -
trunk/exodus/views.py
r6315 r6317 11 11 12 12 from exodus.models import * 13 from exodus.wllogic import freeMasterIP, newSSIDName, addInterlinkIP, freeInterlinkIP 13 from exodus.wllogic import freeMasterIP, newSSIDName, addInterlinkIP, freeInterlinkIP, freePublicAPIP 14 14 15 15 class AddLocationForm(forms.ModelForm): … … 203 203 class Meta: 204 204 model = PublicAP 205 exclude = ('shortdesc', 'desc' )205 exclude = ('shortdesc', 'desc', 'ip', 'dhcpstart', 'dhcpstop') 206 206 207 207 def addPublicAP(request): … … 210 210 if form.is_valid(): 211 211 instance = form.save(commit=False) 212 # Find IP range inside interface range with disired size/subnet 213 instance.ip = freePublicAPIP(instance.iface, instance.netmask) 214 instance.dhcpstart = 1 215 instance.dhcpstop = 2 216 # If wireless generate ssid name 212 217 instance.ssid = newSSIDName(instance.iface.node, instance.iface, 'omni') 213 218 instance.save() 214 return HttpResponseRedirect(reverse('nodelist')) 215 else: 216 form = addPublicAPForm() 219 nodeName = instance.iface.node 220 return HttpResponseRedirect(reverse('node-detail', args=[nodeName])) 221 else: 222 #XXX: Link, master interfaces only 223 if 'iface' in request.GET: 224 nodeName, interfaceName = request.GET['iface'].split(':') 225 newPublicAP = PublicAP() 226 newPublicAP.iface = Interface.objects.get(iface=interfaceName, node=nodename2id(nodeName)) 227 form = addPublicAPForm(instance=newPublicAP) 228 else: 229 form = addPublicAPForm() 217 230 return render_to_response('addomni.html', {'form': form }) 218 231 -
trunk/exodus/wllogic.py
r6313 r6317 1 1 # (c) Roland van Laar 2 2 3 from exodus.models import Node, Interface 3 from exodus.models import Node, Interface, PublicAP 4 4 5 5 def newSSIDName(node, nic, desc): … … 66 66 return showaddr(i) 67 67 68 # 69 # XXX: Needs merging with freeInterlinkIP as interface could have both AP, interlink difined on one link 70 def freePublicAPIP(masterLink, netmask): 71 taken = {} 72 73 for interface in Interface.objects.filter(link=masterLink): 74 #Grr, needs all interfaces which are master requires a bit of a hack 75 addr = network(interface.ip, interface.netmask) 76 addrMax = broadcast(interface.ip, interface.netmask) 77 while addr < addrMax: 78 taken[addr] = 1 79 addr = addr + 1 80 81 for accessPoint in PublicAP.objects.filter(iface=masterLink): 82 #Grr, needs all interfaces which are master requires a bit of a hack 83 addr = network(accessPoint.ip, accessPoint.netmask) 84 addrMax = broadcast(accessPoint.ip, accessPoint.netmask) 85 while addr < addrMax: 86 taken[addr] = 1 87 addr = addr + 1 88 89 #Should be dynamic based on the number of hosts in here 90 size = netmask 91 numaddrs = 1 << (32 - size) 92 i = network(masterLink.ip,masterLink.netmask) 93 while taken.has_key(i): 94 i = i + numaddrs 95 96 return showaddr(i) 97 68 98 def freeInterlinkIP(masterLink): 69 99 taken = {}
Note:
See TracChangeset
for help on using the changeset viewer.