public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Lou Lecrivain via pve-devel <pve-devel@lists.proxmox.com>
To: pve-devel@lists.proxmox.com
Cc: Lou Lecrivain <lou.lecrivain@wdz.de>,
	Jacob Green <jacobgreen@corporatetools.com>
Subject: [pve-devel] SPAM: [PATCH pve-network v2] ipam: fix #5496
Date: Fri,  6 Dec 2024 11:21:11 +0100	[thread overview]
Message-ID: <mailman.65.1733480497.332.pve-devel@lists.proxmox.com> (raw)

[-- Attachment #1: Type: message/rfc822, Size: 5305 bytes --]

From: Lou Lecrivain <lou.lecrivain@wdz.de>
To: pve-devel@lists.proxmox.com
Cc: Lou Lecrivain <lou.lecrivain@wdz.de>, Jacob Green <jacobgreen@corporatetools.com>, Stefan Hanreich <s.hanreich@proxmox.com>
Subject: SPAM: [PATCH pve-network v2] ipam: fix #5496
Date: Fri,  6 Dec 2024 11:21:11 +0100
Message-ID: <20241206102111.4964-1-lou.lecrivain@wdz.de>

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@corporatetools.com>
Signed-off-by: Lou Lecrivain <lou.lecrivain@wdz.de>
Tested-by: Stefan Hanreich <s.hanreich@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



[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

                 reply	other threads:[~2024-12-06 10:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=mailman.65.1733480497.332.pve-devel@lists.proxmox.com \
    --to=pve-devel@lists.proxmox.com \
    --cc=jacobgreen@corporatetools.com \
    --cc=lou.lecrivain@wdz.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal