[pve-devel] [RFC pve-network 7/9] vnets: add del_ips_from_mac
Alexandre Derumier
aderumier at odiso.com
Mon Nov 13 11:04:17 CET 2023
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
src/PVE/Network/SDN/Subnets.pm | 4 ++--
src/PVE/Network/SDN/Vnets.pm | 12 ++++++++++--
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/PVE/Network/SDN/Subnets.pm b/src/PVE/Network/SDN/Subnets.pm
index 905ec77..2bd1ec8 100644
--- a/src/PVE/Network/SDN/Subnets.pm
+++ b/src/PVE/Network/SDN/Subnets.pm
@@ -257,7 +257,7 @@ sub add_next_free_ip {
#rollback
my $err = $@;
eval {
- PVE::Network::SDN::Subnets::del_ip($zone, $subnetid, $subnet, $ip, $hostname)
+ PVE::Network::SDN::Subnets::del_ip($zone, $subnetid, $subnet, $ip, $hostname, $mac)
};
die $err;
}
@@ -311,7 +311,7 @@ sub add_ip {
#rollback
my $err = $@;
eval {
- PVE::Network::SDN::Subnets::del_ip($zone, $subnetid, $subnet, $ip, $hostname)
+ PVE::Network::SDN::Subnets::del_ip($zone, $subnetid, $subnet, $ip, $hostname, $mac)
};
die $err;
}
diff --git a/src/PVE/Network/SDN/Vnets.pm b/src/PVE/Network/SDN/Vnets.pm
index 2f42da6..6047c98 100644
--- a/src/PVE/Network/SDN/Vnets.pm
+++ b/src/PVE/Network/SDN/Vnets.pm
@@ -144,12 +144,12 @@ sub update_ip {
}
sub del_ip {
- my ($vnetid, $ip, $hostname, $skipdns) = @_;
+ my ($vnetid, $ip, $hostname, $mac, $skipdns) = @_;
return if !$vnetid;
my ($zone, $subnetid, $subnet) = PVE::Network::SDN::Vnets::get_subnet_from_vnet_ip($vnetid, $ip);
- PVE::Network::SDN::Subnets::del_ip($zone, $subnetid, $subnet, $ip, $hostname, $skipdns);
+ PVE::Network::SDN::Subnets::del_ip($zone, $subnetid, $subnet, $ip, $hostname, $mac, $skipdns);
}
sub get_ips_from_mac {
@@ -165,4 +165,12 @@ sub get_ips_from_mac {
return PVE::Network::SDN::Ipams::get_ips_from_mac($mac, $zoneid, $zone);
}
+sub del_ips_from_mac {
+ my ($vnetid, $mac, $hostname) = @_;
+
+ my ($ip4, $ip6) = PVE::Network::SDN::Vnets::get_ips_from_mac($vnetid, $mac);
+ PVE::Network::SDN::Vnets::del_ip($vnetid, $ip4, $hostname, $mac) if $ip4;
+ PVE::Network::SDN::Vnets::del_ip($vnetid, $ip6, $hostname, $mac) if $ip6;
+}
+
1;
--
2.39.2
More information about the pve-devel
mailing list