From 680446f0acd8aa7820974d32b5b4093a6d4e7a10 Mon Sep 17 00:00:00 2001 From: Jay Pipes Date: Fri, 16 Jul 2010 12:00:15 -0500 Subject: Adds a fix to the idempotency of the test_too_many_addresses test case by adding a simple property to the BaseNetwork class and calculating the number of available IPs by asking the network class to tell the test how many static and preallocated IP addresses are in use before entering the loop to "blow up" the address allocation... --- nova/compute/network.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'nova/compute') diff --git a/nova/compute/network.py b/nova/compute/network.py index 8592d7af7..2b271d0ca 100644 --- a/nova/compute/network.py +++ b/nova/compute/network.py @@ -164,6 +164,7 @@ class Vlan(datastore.BasicModel): class BaseNetwork(datastore.BasicModel): override_type = 'network' + NUM_STATIC_IPS = 3 # Network, Gateway, and CloudPipe @property def identifier(self): @@ -239,11 +240,15 @@ class BaseNetwork(datastore.BasicModel): def available(self): # the .2 address is always CloudPipe # and the top are for vpn clients - for idx in range(3, len(self.network)-(1 + FLAGS.cnt_vpn_clients)): + for idx in range(self.num_static_ips, len(self.network)-(1 + FLAGS.cnt_vpn_clients)): address = str(self.network[idx]) if not address in self.hosts.keys(): yield str(address) + @property + def num_static_ips(self): + return BaseNetwork.NUM_STATIC_IPS + def allocate_ip(self, user_id, project_id, mac): for address in self.available: logging.debug("Allocating IP %s to %s" % (address, project_id)) -- cgit