From 2cb80e1d1eddf9a34e34993e0b7c04ae74c316ea Mon Sep 17 00:00:00 2001 From: Apollon Oikonomopoulos <apollon@noc.grnet.gr> Date: Wed, 8 Jun 2011 19:23:00 +0300 Subject: [PATCH] Handle StopIteration in free IP generation Catch the StopIteration exception and return None to the temporary_ips reservation manager, so that it fails at the 64-attempt boundary. Signed-off-by: Apollon Oikonomopoulos <apollon@noc.grnet.gr> --- lib/config.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/config.py b/lib/config.py index 0323a9cbf..cdbdd78f3 100644 --- a/lib/config.py +++ b/lib/config.py @@ -350,7 +350,14 @@ class ConfigWriter: nobj = self._UnlockedGetNetwork(net_uuid) pool = network.AddressPool(nobj) gen_free = pool.GenerateFree() - gen_one = lambda: (gen_free(), net_uuid) + + def gen_one(): + try: + ip = gen_free() + except StopIteration: + return None + return (ip, net_uuid) + address, _ = self._temporary_ips.Generate([], gen_one, ec_id) return address -- GitLab