Index: /trunk/exodus/forms.py
===================================================================
--- /trunk/exodus/forms.py	(revision 6458)
+++ /trunk/exodus/forms.py	(revision 6459)
@@ -1,7 +1,12 @@
 from django import forms
-from exodus.models import Node, Interface
+from exodus.models import Location, Node, Interface
 from exodus.wllogic import free_master_ip, link_has_compat_type, \
         link_is_wireless, new_ssid
 from exodus.wllogic import MASTER, MANAGED
+from exodus.wlipcalc import IPCalc
+
+class LocationForm(forms.ModelForm):
+    class Meta:
+        model = Location
 
 class NodeForm(forms.ModelForm):
@@ -34,5 +39,6 @@
         type = self.cleaned_data.get('type')
 
-        # self.instance raises DoesNotExist, but self.instance.[pk, ssid, polar, etc] doesn't
+        # self.instance raises DoesNotExist, 
+        # but self.instance.[pk, ssid, polar, etc] doesn't
         # Primary Keys's always start at 1.
         if self.instance.pk:
@@ -45,4 +51,11 @@
             if self.instance.pk == link.pk:
                 return link
+
+            # check if the two links are compatible
+            elif not link_has_compat_type(link.type, type):
+                raise forms.ValidationError( 
+                    'Link type %s is not compatible with %s' 
+                    %(link.type, type))
+
             # Link can't be to same node, unless link is to self, 
             # which we checked above.
@@ -54,10 +67,4 @@
                     self.instance.pk != link.pk:
                 raise forms.ValidationError( "A link can't be made to another interface when this interface has an accesspoint.")
-
-            # check if the two links are compatible
-            elif not link_has_compat_type(link.type, type):
-                raise forms.ValidationError( 
-                    'Link type %s is not compatible with %s' 
-                    %(link.type, type))
 
             # if link is referenced to itself, link is master and linkable
@@ -93,6 +100,10 @@
                 new_master.ssid = ssid
                 new_slave.ssid = ssid
-                #XXX: do ip address switch stuff
-                # 
+
+                # calc the new ipaddresses
+                ip = IPCalc(new_master.node, 30)  
+                new_master.ip , new_slave.ip = ip.ips
+                new_master.netmask = new_slave.netmask = 30
+                    
                 # Save 
                 new_master.save()
Index: /trunk/exodus/scripts/genesis_to_exodus.py
===================================================================
--- /trunk/exodus/scripts/genesis_to_exodus.py	(revision 6458)
+++ /trunk/exodus/scripts/genesis_to_exodus.py	(revision 6459)
@@ -2,4 +2,5 @@
 
 def run():
+    import pdb; pdb.set_trace() ;
     """Import script for genesis data."""
     print """Import script for genesis."""
Index: /trunk/exodus/tests.py
===================================================================
--- /trunk/exodus/tests.py	(revision 6458)
+++ /trunk/exodus/tests.py	(revision 6459)
@@ -49,8 +49,15 @@
 
     def test_ipcalc_get_used_ips(self):
-        self.fail("Test not implemented")
+        list = ['172.16.0.1', '172.16.0.2', '172.16.0.4', '172.16.0.5', 
+                '172.16.0.6', '172.16.0.7']
+        used_list = self.ipcalc(30)._get_used_ips()
+        used_list.sort()
+        self.failUnlessEqual( list, used_list)
 
     def test_ipcalc_get_free_network_addr(self):
-        self.fail("Test not implemented")
+        list = ['172.16.0.1', '172.16.0.2', '172.16.0.4', '172.16.0.5', 
+                '172.16.0.6', '172.16.0.7']
+        network_addr = self.ipcalc(30)._get_free_network_addr(list)
+        self.failUnlessEqual(network_addr, '172.16.0.8')
 
     def test_ipcalc_out_of_bounds(self):
Index: /trunk/exodus/wlipcalc.py
===================================================================
--- /trunk/exodus/wlipcalc.py	(revision 6458)
+++ /trunk/exodus/wlipcalc.py	(revision 6459)
@@ -31,5 +31,5 @@
             self.network = wl.show_addr(network)
   
-        # variables for extenal calling
+        # variables for external calling
         self.netmask = free_netmask
         if free_netmask == 32:
@@ -42,4 +42,5 @@
             for i in range(1, self.new_ip_size-1):
                 self.ips.append(wl.show_addr(network + i))                    
+
     def _ip_size(self, netmask):
         return int(pow(2,32 - netmask))
@@ -77,3 +78,2 @@
                     return  network_addr
         return None
-
