- Timestamp:
- Jan 24, 2009, 1:33:22 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/base.cfg
r6491 r6637 7 7 8 8 [versions] 9 djangorecipe=0.1 2.19 djangorecipe=0.15 10 10 zc.recipe.egg=1.0.0 11 11 zc.recipe.testrunner=1.0.0 … … 29 29 recipe = iw.recipe.subversion 30 30 urls = 31 http://django-command-extensions.googlecode.com/svn/trunk@1 35django-command-extensions31 http://django-command-extensions.googlecode.com/svn/trunk@178 django-command-extensions 32 32 33 33 [django] -
trunk/exodus/models.py
r6606 r6637 117 117 118 118 class Interface(models.Model): 119 120 def all(self):121 return Interface.objects.all()122 119 node = models.ForeignKey(Node) 123 120 ethernet_to_wifi = models.ForeignKey(EthernetToWifiBridge, blank=True, -
trunk/exodus/tests/base.py
r6607 r6637 27 27 # create multiple nodes. 28 28 from exodus.models import Node 29 nod1 = Node.objects.create(name='Roland', location=loc1, status='up',30 network=network, masterip='172.16.0.1')31 nod2 = Node.objects.create(name='Rick', location=loc2, status='up',29 self.nod1 = Node.objects.create(name='Roland', location=loc1, 30 status='up', network=network, masterip='172.16.0.1') 31 self.nod2 = Node.objects.create(name='Rick', location=loc2, status='up', 32 32 network=network, masterip='172.16.1.1') 33 nod3 = Node.objects.create(name='Andrea', location=loc3, status='up',34 network=network, masterip='172.16.2.1')33 self.nod3 = Node.objects.create(name='Andrea', location=loc3, 34 status='up', network=network, masterip='172.16.2.1') 35 35 36 36 def tearDown(self): -
trunk/exodus/tests/test_wlipcalc.py
r6608 r6637 4 4 class IPCalcTest(BootstrapTestCase): 5 5 6 def ipcalc(a): 6 def setUp(self): 7 super(IPCalcTest, self).setUp() 8 from exodus.models import Interface 9 self.iface1 = Interface.objects.create(node = self.nod1, type='eth', 10 iface='eth0', ip='172.16.0.2', netmask=32, link=None) 11 self.iface2 = Interface.objects.create(node = self.nod1, type='11b', 12 iface='wi0', ip='172.16.0.5', netmask=30, link=None) 13 self.iface3 = Interface.objects.create(node = self.nod2, type='11b', 14 iface='wi0', ip='172.16.0.6', netmask=30, link=self.iface2) 15 16 def ipcalc(self, a): 7 17 from exodus.models import Node 8 18 node = Node.objects.get(pk=1) … … 22 32 23 33 def test_ipcalc_get_used_ips_with_link(self): 24 from exodus.models import Interface 25 link_id = Interface.objects.get(pk=1).id 34 link_id = self.iface2.id 26 35 list = set(['172.16.0.1', '172.16.0.2']) 27 36 from exodus.wlipcalc import IPCalc 28 used_list = IPCalc(self.nod e, 30, link_id)._get_used_ips()37 used_list = IPCalc(self.nod1, 30, link_id)._get_used_ips() 29 38 self.failUnlessEqual(list, used_list) 30 39 … … 43 52 from exodus.models import Interface 44 53 iface = Interface.objects.create( 45 node = self.nod e, type = 'eth', iface ='eth3',46 ip = '172.16.0.130', netmask = 25 )54 node = self.nod1, type = 'eth', iface ='eth3', 55 ip = '172.16.0.130', netmask = 25, link=None) 47 56 48 57 self.failUnlessRaises(Exception, self.ipcalc, 25) … … 54 63 55 64 self.failUnlessEqual(ipcalc.network, ip) 56 self.failUnlessEqual(ipcalc.ips, ip) 65 # ipcalc.ips returns a list, which in this case has one ip. 66 self.failUnlessEqual(ipcalc.ips, [ip]) 57 67 self.failUnlessEqual(ipcalc.broadcast, ip) 58 68 self.failUnlessEqual(ipcalc.netmask, netmask) -
trunk/exodus/tests/test_wllogic.py
r6608 r6637 18 18 def test_new_ssid(self): 19 19 #XXX: need to test 'ap', direction and multiple aps on one node. 20 class Interface_Set(object): 21 def filter(self, accesspoint): 22 return () 20 23 class node(object): 21 24 name = 'CeTIM' 25 interface_set = Interface_Set() 26 22 27 class network(object): 23 28 name = 'wleiden.net' 24 29 from exodus.wllogic import new_ssid 30 # plain 25 31 ssid = new_ssid(network(), node(), 'ath0') 26 27 32 self.failUnlessEqual(ssid, 'ath0.CeTIM.wleiden.net') 33 # with an ap 34 ssid = new_ssid(network(), node(), 'ath0', accesspoint=True) 35 self.failUnlessEqual(ssid, 'ap.CeTIM.wleiden.net') 36 # with a direction 37 ssid = new_ssid(network(), node(), 'ath0', direction='sw') 38 self.failUnlessEqual(ssid, 'sw.CeTIM.wleiden.net') 39 # with an ap and a direction 40 ssid = new_ssid(network(), node(), 'ath0', accesspoint=True, 41 direction='sw') 42 self.failUnlessEqual(ssid, 'ap.CeTIM.wleiden.net') 43 # with two aps, first ap is ap.CeTIM.wleiden.net. 44 class iface(object): 45 def __init__(self, number): 46 essid = "ap%s.CeTIM.wleiden.net" 47 if number == 1: 48 self.ssid = essid % ("") 49 else: 50 self.ssid = essid % (number) 51 52 class Interface_Set(object): 53 def filter(self, accesspoint): 54 return (iface(1),) 55 class node(object): 56 name = 'CeTIM' 57 interface_set = Interface_Set() 58 59 ssid = new_ssid(network(), node(), 'ath0', accesspoint=True) 60 self.failUnlessEqual(ssid, 'ap2.CeTIM.wleiden.net') 61 # with two aps. second ap is ap2.CeTIM.wleiden.net 62 class Interface_Set(object): 63 def filter(self, accesspoint): 64 return (iface(2),) 65 class node(object): 66 name = 'CeTIM' 67 interface_set = Interface_Set() 68 69 ssid = new_ssid(network(), node(), 'ath0', accesspoint=True) 70 self.failUnlessEqual(ssid, 'ap.CeTIM.wleiden.net') 71 28 72 29 73 def test_new_ssid_for_existing_interface(self): 30 self.fail('Not yet implemented') 74 class nic(object): 75 iface='ath0' 76 accesspoint=False 77 def get_direction_display(self): 78 return 'sw' 79 class node(object): 80 name='CeTIM' 81 class network(object): 82 name='wleiden.net' 83 84 from exodus.wllogic import new_ssid_for_existing_interface 85 ssid = new_ssid_for_existing_interface(nic()) 86 self.failUnlessEqual(ssid, 'sw.CeTIM.wleiden.net') 31 87 32 88 def test_parse_show_addr(self): … … 188 244 self.failUnless(link_is_wireless(self.link20)) 189 245 self.failUnless(link_is_wireless(self.link30)) 246 190 247 def suite(): 191 248 s = unittest.TestSuite() -
trunk/exodus/views.py
r6618 r6637 59 59 else: 60 60 mode = 'slave' 61 writer.writerow([nic.iface, node.name, nic.type, nic.ssid, nic.channel, 62 nic.antenna, nic.get_polar_display(), nic.get_direction_display(), 63 mode, nic.ip, nic.netmask, nic.link.node, nic.link.iface]) 61 writer.writerow([nic.iface, node.name, nic.type, nic.ssid, 62 nic.channel, nic.antenna, nic.get_polar_display(), 63 nic.get_direction_display(), mode, nic.ip, nic.netmask, 64 nic.link.node, nic.link.iface]) 64 65 return response 65 66 -
trunk/exodus/wllogic.py
r6608 r6637 117 117 return show_addr(i+1) 118 118 119 def calc_subnet(number_ifaces): 120 #XXX: rename this to calc_netmask 121 """Returns the netmask. 122 123 We need the subnet with number_ifaces available in subnet. As such 124 we correct for the broadcast and network address. 125 """ 126 if number_ifaces > 254 or number_ifaces < 1: 127 raise ValueError, 'Number of ifaces is out of bounds' 128 if number_ifaces == 1: 129 return 32 130 return int(32) - int(ceil(log(number_ifaces+2,2))) 131 119 132 def link_is_wireless(iface): 120 133 """Check if the interface is wireless""" … … 133 146 return link1.node != link2.node 134 147 135 def calc_subnet(number_ifaces):136 #XXX: rename this to calc_netmask137 """Returns the netmask.138 139 We need the subnet with number_ifaces available in subnet. As such140 we correct for the broadcast and network address.141 """142 if number_ifaces > 254 or number_ifaces < 1:143 raise ValueError, 'Number of ifaces is out of bounds'144 if number_ifaces == 1:145 return 32146 return int(32) - int(ceil(log(number_ifaces+2,2)))
Note:
See TracChangeset
for help on using the changeset viewer.