summaryrefslogtreecommitdiff
path: root/src/PVE/Network/SDN/Ipams/Plugin.pm
diff options
context:
space:
mode:
authorStefan Hanreich <s.hanreich@proxmox.com>2025-03-10 09:51:03 +0100
committerThomas Lamprecht <t.lamprecht@proxmox.com>2025-04-07 17:43:56 +0200
commit1b01ad6529516790cc19b22c2c389e1c41530738 (patch)
tree61858901e7ade9bb526f53a4265b200b72df5da3 /src/PVE/Network/SDN/Ipams/Plugin.pm
parenta52a40c78b82e0646c60a28fc9919336a2cb1290 (diff)
partial fix #5496: subnet: ipam: add update_subnet hook
Because of how the Netbox IPAM plugin works (utilizing IP ranges to represent DHCP ranges), we need a hook in the IPAM plugin that runs on updates to the subnet because DHCP ranges can be edited. The update hook in Netbox checks which DHCP ranges got added and which got deleted and then performs the respective changes in the Netbox IPAM. This operates under the assumption that DHCP ranges do not overlap (which is not supported by Netbox anyway). Only Netbox needs to do work on update, so we can leave this as noop in phpIPAM and the PVE IPAM, because they have no notion of IP ranges or similar entities. phpIPAM doesn't support DHCP ranges at all and PVE IPAM simply uses DHCP ranges as a constraint when allocating an IP. I decided on this approach over just creating IP ranges on demand when assigning IPs, because this keeps Netbox clean and in sync with the PVE state. It doesn't leave remnants of IP ranges in the Netbox database, which can lead to errors when trying to create IP ranges that overlap with IP ranges that already existed in an SDN subnet. This method tries to check for any possible errors before editing the entities. There is still a small window where external changes can occur that lead to errors. We are touching multiple entities here, so in case of errors users have to fix their Netbox instance manually. Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com> Tested-by: Hannes Duerr <h.duerr@proxmox.com> Link: https://lore.proxmox.com/20250310085103.30549-8-s.hanreich@proxmox.com Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Diffstat (limited to 'src/PVE/Network/SDN/Ipams/Plugin.pm')
-rw-r--r--src/PVE/Network/SDN/Ipams/Plugin.pm6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/PVE/Network/SDN/Ipams/Plugin.pm b/src/PVE/Network/SDN/Ipams/Plugin.pm
index ab4cae8..6190c24 100644
--- a/src/PVE/Network/SDN/Ipams/Plugin.pm
+++ b/src/PVE/Network/SDN/Ipams/Plugin.pm
@@ -75,6 +75,12 @@ sub add_subnet {
die "please implement inside plugin";
}
+sub update_subnet {
+ my ($class, $plugin_config, $subnetid, $subnet, $old_subnet, $noerr) = @_;
+
+ die "please implement inside plugin";
+}
+
sub del_subnet {
my ($class, $plugin_config, $subnetid, $subnet, $noerr) = @_;