def get_network_pool(gnet): """Return available and reserved IP maps. Extract the available and reserved IP map from the info return from Ganeti for a network. """ converter = IPPool(Foo(gnet['network'])) a_map = bitarray_from_map(gnet['map']) a_map.invert() reserved = gnet['external_reservations'] r_map = a_map.copy() r_map.setall(True) for address in reserved.split(','): index = converter.value_to_index(address) a_map[index] = True r_map[index] = False return a_map, r_map