| | |
| | | if not self.subpool.subnet_of(self.pool): |
| | | raise InputValidationException('Subpool must be a subnet of pool') |
| | | |
| | | self.validate = self.options.get('validate', '1') == '1' |
| | | self.ptp = self.options.get('ptp', '0') == '1' |
| | | |
| | | self.allocations = set() |
| | |
| | | raise InputValidationException('Requested address does not belong to a pool') |
| | | |
| | | address = str(address) |
| | | if self._is_allocated(address): |
| | | if self.validate and self._is_allocated(address): |
| | | raise InputValidationException('Requested address {} is already used'.format(address)) |
| | | self.allocations.add(address) |
| | | |
| | |
| | | check[str(pool)] = pool |
| | | return str(pool) |
| | | |
| | | def get_pool(self, pool: str) -> Pool: |
| | | def has_pool(self, pool_id: str) -> bool: |
| | | return pool_id in self.pools or pool_id in self.pools6 |
| | | |
| | | def get_pool(self, pool: str | Pool) -> Pool: |
| | | pool = str(pool) |
| | | if pool in self.pools: |
| | | return self.pools[pool] |
| | |
| | | else: |
| | | raise InputValidationException('Unknown pool {}'.format(pool)) |
| | | |
| | | def remove_pool(self, pool: str): |
| | | def remove_pool(self, pool: str | Pool): |
| | | pool = str(pool) |
| | | if pool in self.pools: |
| | | del self.pools[pool] |