Changeset 6475 for trunk


Ignore:
Timestamp:
Dec 22, 2008, 12:33:35 PM (16 years ago)
Author:
roland
Message:

Fixed bug where self.link.id was called, when self.link was null.
This resulted in an Exception.

Location:
trunk/exodus
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/exodus/tests.py

    r6469 r6475  
    5252                '172.16.0.6', '172.16.0.7'])
    5353        used_list = self.ipcalc(30)._get_used_ips()
    54         self.failUnlessEqual( list, used_list)
     54        self.failUnlessEqual(list, used_list)
     55
     56    def test_ipcalc_get_used_ips_with_link(self):
     57        from exodus.models import Interface
     58        link_id = Interface.objects.get(pk=1).id
     59        list = set(['172.16.0.1', '172.16.0.2'])
     60        from exodus.wlipcalc import IPCalc
     61        used_list = IPCalc(self.node, 30, link_id)._get_used_ips()
     62        self.failUnlessEqual(list, used_list)
    5563
    5664    def test_ipcalc_get_free_network_addr(self):
  • trunk/exodus/wlipcalc.py

    r6472 r6475  
    99    """
    1010
    11     def __init__(self, node, free_netmask, link = None):
     11    def __init__(self, node, free_netmask, link_id = None):
    1212        if free_netmask <= MASTERIP_NETMASK or free_netmask > 32:
    1313            raise ValueError, 'Netmask out of bounds.'
     
    1717        master_netmask = MASTERIP_NETMASK
    1818        self.master_network = wl.get_network(self.master_ip, master_netmask)
    19         self.link = link
     19        self.link_id = link_id
    2020
    2121        # calculate the number of ipaddresses in the subnetmask
     
    5757        for i in self.node.interface_set.all():
    5858            #XXX: rewrite to if i.ip in masterip??
    59             # not i.id == self.link.id, don't populate used_list
     59            # not i.id == self.link_id, don't populate used_list
    6060            # with ips from it's own netmask
    61             if self.link:
    62                 if i.id == i.link_id and not i.id == self.link.id:
     61            #if self.link:
     62                if i.id == i.link_id and not i.id == self.link_id:
    6363                    ip_size = self._ip_size(i.netmask)
    6464                    network_addr = wl.network(i.ip, i.netmask)
Note: See TracChangeset for help on using the changeset viewer.