pyIPAM - Docker Plugin for IPAM written in Python
Jacek Kowalski
yesterday 79ead105749963216bf8689b1294cd9e7985bb7e
lib/Ipam.py
@@ -41,6 +41,7 @@
        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()
@@ -84,7 +85,7 @@
            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)
@@ -119,7 +120,10 @@
        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]
@@ -128,7 +132,7 @@
        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]