SPAM: [PATCH pve-network v2] ipam: fix #5496
Lou Lecrivain
lou.lecrivain at wdz.de
Fri Dec 6 11:21:11 CET 2024
functions were returning undef despite API calls being successfull,
due to eval blocks return values not being taken into account.
Co-authored-by: Jacob Green <jacobgreen at corporatetools.com>
Signed-off-by: Lou Lecrivain <lou.lecrivain at wdz.de>
Tested-by: Stefan Hanreich <s.hanreich at proxmox.com>
---
src/PVE/Network/SDN/Ipams/NetboxPlugin.pm | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/PVE/Network/SDN/Ipams/NetboxPlugin.pm b/src/PVE/Network/SDN/Ipams/NetboxPlugin.pm
index d923269..124c355 100644
--- a/src/PVE/Network/SDN/Ipams/NetboxPlugin.pm
+++ b/src/PVE/Network/SDN/Ipams/NetboxPlugin.pm
@@ -151,7 +151,7 @@ sub add_next_freeip {
my $params = { dns_name => $hostname, description => $description };
- eval {
+ my $ip = eval {
my $result = PVE::Network::SDN::api_request("POST", "$url/ipam/prefixes/$internalid/available-ips/", $headers, $params);
my ($ip, undef) = split(/\//, $result->{address});
return $ip;
@@ -160,6 +160,8 @@ sub add_next_freeip {
if ($@) {
die "can't find free ip in subnet $cidr: $@" if !$noerr;
}
+
+ return $ip;
}
sub add_range_next_freeip {
@@ -174,7 +176,7 @@ sub add_range_next_freeip {
my $params = { dns_name => $data->{hostname}, description => $description };
- eval {
+ my $ip = eval {
my $result = PVE::Network::SDN::api_request("POST", "$url/ipam/ip-ranges/$internalid/available-ips/", $headers, $params);
my ($ip, undef) = split(/\//, $result->{address});
print "found ip free $ip in range $range->{'start-address'}-$range->{'end-address'}\n" if $ip;
@@ -184,6 +186,8 @@ sub add_range_next_freeip {
if ($@) {
die "can't find free ip in range $range->{'start-address'}-$range->{'end-address'}: $@" if !$noerr;
}
+
+ return $ip;
}
sub del_ip {
--
2.39.5
More information about the pve-devel
mailing list