Changeset 6459
- Timestamp:
- Dec 15, 2008, 12:17:45 PM (16 years ago)
- Location:
- trunk/exodus
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/exodus/forms.py
r6454 r6459 1 1 from django import forms 2 from exodus.models import Node, Interface2 from exodus.models import Location, Node, Interface 3 3 from exodus.wllogic import free_master_ip, link_has_compat_type, \ 4 4 link_is_wireless, new_ssid 5 5 from exodus.wllogic import MASTER, MANAGED 6 from exodus.wlipcalc import IPCalc 7 8 class LocationForm(forms.ModelForm): 9 class Meta: 10 model = Location 6 11 7 12 class NodeForm(forms.ModelForm): … … 34 39 type = self.cleaned_data.get('type') 35 40 36 # self.instance raises DoesNotExist, but self.instance.[pk, ssid, polar, etc] doesn't 41 # self.instance raises DoesNotExist, 42 # but self.instance.[pk, ssid, polar, etc] doesn't 37 43 # Primary Keys's always start at 1. 38 44 if self.instance.pk: … … 45 51 if self.instance.pk == link.pk: 46 52 return link 53 54 # check if the two links are compatible 55 elif not link_has_compat_type(link.type, type): 56 raise forms.ValidationError( 57 'Link type %s is not compatible with %s' 58 %(link.type, type)) 59 47 60 # Link can't be to same node, unless link is to self, 48 61 # which we checked above. … … 54 67 self.instance.pk != link.pk: 55 68 raise forms.ValidationError( "A link can't be made to another interface when this interface has an accesspoint.") 56 57 # check if the two links are compatible58 elif not link_has_compat_type(link.type, type):59 raise forms.ValidationError(60 'Link type %s is not compatible with %s'61 %(link.type, type))62 69 63 70 # if link is referenced to itself, link is master and linkable … … 93 100 new_master.ssid = ssid 94 101 new_slave.ssid = ssid 95 #XXX: do ip address switch stuff 96 # 102 103 # calc the new ipaddresses 104 ip = IPCalc(new_master.node, 30) 105 new_master.ip , new_slave.ip = ip.ips 106 new_master.netmask = new_slave.netmask = 30 107 97 108 # Save 98 109 new_master.save() -
trunk/exodus/scripts/genesis_to_exodus.py
r6456 r6459 2 2 3 3 def run(): 4 import pdb; pdb.set_trace() ; 4 5 """Import script for genesis data.""" 5 6 print """Import script for genesis.""" -
trunk/exodus/tests.py
r6458 r6459 49 49 50 50 def test_ipcalc_get_used_ips(self): 51 self.fail("Test not implemented") 51 list = ['172.16.0.1', '172.16.0.2', '172.16.0.4', '172.16.0.5', 52 '172.16.0.6', '172.16.0.7'] 53 used_list = self.ipcalc(30)._get_used_ips() 54 used_list.sort() 55 self.failUnlessEqual( list, used_list) 52 56 53 57 def test_ipcalc_get_free_network_addr(self): 54 self.fail("Test not implemented") 58 list = ['172.16.0.1', '172.16.0.2', '172.16.0.4', '172.16.0.5', 59 '172.16.0.6', '172.16.0.7'] 60 network_addr = self.ipcalc(30)._get_free_network_addr(list) 61 self.failUnlessEqual(network_addr, '172.16.0.8') 55 62 56 63 def test_ipcalc_out_of_bounds(self): -
trunk/exodus/wlipcalc.py
r6458 r6459 31 31 self.network = wl.show_addr(network) 32 32 33 # variables for exte nal calling33 # variables for external calling 34 34 self.netmask = free_netmask 35 35 if free_netmask == 32: … … 42 42 for i in range(1, self.new_ip_size-1): 43 43 self.ips.append(wl.show_addr(network + i)) 44 44 45 def _ip_size(self, netmask): 45 46 return int(pow(2,32 - netmask)) … … 77 78 return network_addr 78 79 return None 79
Note:
See TracChangeset
for help on using the changeset viewer.