ipam: netbox: add error handling to get_ips_from_mac

This function did not catch any possible errors, nor respect the
$noerr parameter.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Tested-by: Hannes Duerr <h.duerr@proxmox.com>
Link: https://lore.proxmox.com/20250310085103.30549-5-s.hanreich@proxmox.com
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Stefan Hanreich 2025-03-10 09:51:00 +01:00 committed by Thomas Lamprecht
parent 5ff8aeb080
commit b673a106c5

View file

@ -247,6 +247,10 @@ sub get_ips_from_mac {
my $data = eval { my $data = eval {
netbox_api_request($plugin_config, "GET", "/ipam/ip-addresses/?description__ic=$mac"); netbox_api_request($plugin_config, "GET", "/ipam/ip-addresses/?description__ic=$mac");
}; };
if ($@) {
return if $noerr;
die "could not query ip address entry for mac $mac: $@";
}
for my $ip (@{$data->{results}}) { for my $ip (@{$data->{results}}) {
if ($ip->{family}->{value} == 4 && !$ip4) { if ($ip->{family}->{value} == 4 && !$ip4) {