Commit 861a92b4 authored by Dimitris Aragiorgis's avatar Dimitris Aragiorgis Committed by Iustin Pop
Browse files

Use bitarray 0.8 interface


Signed-off-by: default avatarDimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent cfcea7ef
# #
# #
# Copyright (C) 2011 Google Inc. # Copyright (C) 2011, 2012 Google Inc.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
...@@ -37,6 +37,9 @@ class AddressPool(object): ...@@ -37,6 +37,9 @@ class AddressPool(object):
L{objects.Network} objects. L{objects.Network} objects.
""" """
FREE = bitarray('0')
RESERVED = bitarray('1')
def __init__(self, network): def __init__(self, network):
"""Initialize a new IPv4 address pool from an objects.Network object """Initialize a new IPv4 address pool from an objects.Network object
...@@ -179,12 +182,13 @@ class AddressPool(object): ...@@ -179,12 +182,13 @@ class AddressPool(object):
""" """
if self.IsFull(): if self.IsFull():
raise errors.AddressPoolError("%s is full" % self.network) raise errors.AddressPoolError("%s is full" % self.network)
idx = self.all_reservations.search("0", 1) idx = self.all_reservations.search(self.FREE, 1)
return str(self.network[idx]) return str(self.network[idx])
def GetExternalReservations(self): def GetExternalReservations(self):
"""Returns a list of all externally reserved addresses""" """Returns a list of all externally reserved addresses"""
idxs = self.ext_reservations.search("1") # pylint: disable=E1103
idxs = self.ext_reservations.search(self.RESERVED)
return [str(self.network[idx]) for idx in idxs] return [str(self.network[idx]) for idx in idxs]
@classmethod @classmethod
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment