Revision 861a92b4
b/lib/network.py | ||
---|---|---|
1 | 1 |
# |
2 | 2 |
# |
3 | 3 |
|
4 |
# Copyright (C) 2011 Google Inc. |
|
4 |
# Copyright (C) 2011, 2012 Google Inc.
|
|
5 | 5 |
# |
6 | 6 |
# This program is free software; you can redistribute it and/or modify |
7 | 7 |
# it under the terms of the GNU General Public License as published by |
... | ... | |
37 | 37 |
L{objects.Network} objects. |
38 | 38 |
|
39 | 39 |
""" |
40 |
FREE = bitarray('0') |
|
41 |
RESERVED = bitarray('1') |
|
42 |
|
|
40 | 43 |
def __init__(self, network): |
41 | 44 |
"""Initialize a new IPv4 address pool from an objects.Network object |
42 | 45 |
|
... | ... | |
179 | 182 |
""" |
180 | 183 |
if self.IsFull(): |
181 | 184 |
raise errors.AddressPoolError("%s is full" % self.network) |
182 |
idx = self.all_reservations.search("0", 1)
|
|
185 |
idx = self.all_reservations.search(self.FREE, 1)
|
|
183 | 186 |
return str(self.network[idx]) |
184 | 187 |
|
185 | 188 |
def GetExternalReservations(self): |
186 | 189 |
"""Returns a list of all externally reserved addresses""" |
187 |
idxs = self.ext_reservations.search("1") |
|
190 |
# pylint: disable=E1103 |
|
191 |
idxs = self.ext_reservations.search(self.RESERVED) |
|
188 | 192 |
return [str(self.network[idx]) for idx in idxs] |
189 | 193 |
|
190 | 194 |
@classmethod |
Also available in: Unified diff