From 1878defa477812781b78f00f5e389304217de698 Mon Sep 17 00:00:00 2001
From: Jacek Kowalski <Jacek@jacekk.info>
Date: Sun, 03 May 2026 12:45:19 +0000
Subject: [PATCH] Persist IPAM pool data

---
 lib/Ipam.py |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/lib/Ipam.py b/lib/Ipam.py
index 2cffed2..73f4f67 100644
--- a/lib/Ipam.py
+++ b/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]

--
Gitblit v1.10.0