From 55f70aef3c715c3a958915193a9d2e0696f7fe46 Mon Sep 17 00:00:00 2001 From: Dimitris Aragiorgis Date: Fri, 23 Nov 2012 10:32:47 +0200 Subject: [PATCH] Fix bug in network module Signed-off-by: Dimitris Aragiorgis Signed-off-by: Iustin Pop [iustin@google.com: slightly improved code flow] Reviewed-by: Iustin Pop --- lib/network.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/network.py b/lib/network.py index 736a03a..cc3bfd6 100644 --- a/lib/network.py +++ b/lib/network.py @@ -201,10 +201,11 @@ class AddressPool(object): @raise errors.AddressPoolError: Pool is full """ - if self.IsFull(): - raise errors.AddressPoolError("%s is full" % self.network) idx = self.all_reservations.search(self.FREE, 1) - return str(self.network[idx]) + if idx: + return str(self.network[idx[0]]) + else: + raise errors.AddressPoolError("%s is full" % self.network) def GetExternalReservations(self): """Returns a list of all externally reserved addresses. -- 1.7.10.4