diff options
| author | Alexandre Derumier <aderumier@odiso.com> | 2024-01-04 17:11:36 +0100 |
|---|---|---|
| committer | Thomas Lamprecht <t.lamprecht@proxmox.com> | 2024-01-22 12:06:55 +0100 |
| commit | b906257d4a51f1c7d21ff1513a7076cb7013e2d6 (patch) | |
| tree | c9f4736567c90aee944cc214c04ffb6403869071 | |
| parent | 6e96fd3314b6d355b6f9df4712b721e08b0ccd11 (diff) | |
ipams : add_next_freeip : return ip not cidr
we want same result than add_next_free_range
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
| -rw-r--r-- | src/PVE/Network/SDN/Ipams/NetboxPlugin.pm | 13 | ||||
| -rw-r--r-- | src/PVE/Network/SDN/Ipams/PVEPlugin.pm | 2 | ||||
| -rw-r--r-- | src/PVE/Network/SDN/Ipams/PhpIpamPlugin.pm | 2 |
3 files changed, 6 insertions, 11 deletions
diff --git a/src/PVE/Network/SDN/Ipams/NetboxPlugin.pm b/src/PVE/Network/SDN/Ipams/NetboxPlugin.pm index 91010bb..14a69d9 100644 --- a/src/PVE/Network/SDN/Ipams/NetboxPlugin.pm +++ b/src/PVE/Network/SDN/Ipams/NetboxPlugin.pm @@ -151,17 +151,15 @@ sub add_next_freeip { my $params = { dns_name => $hostname, description => $description }; - my $ip = undef; eval { my $result = PVE::Network::SDN::api_request("POST", "$url/ipam/prefixes/$internalid/available-ips/", $headers, $params); - $ip = $result->{address}; + my ($ip, undef) = split(/\//, $result->{address}); + return $ip; }; if ($@) { die "can't find free ip in subnet $cidr: $@" if !$noerr; } - - return $ip; } sub add_range_next_freeip { @@ -176,19 +174,16 @@ sub add_range_next_freeip { my $params = { dns_name => $data->{hostname}, description => $description }; - my $ip = undef; eval { my $result = PVE::Network::SDN::api_request("POST", "$url/ipam/ip-ranges/$internalid/available-ips/", $headers, $params); - $ip = $result->{address}; + my ($ip, undef) = split(/\//, $result->{address}); print "found ip free $ip in range $range->{'start-address'}-$range->{'end-address'}\n" if $ip; + return $ip; }; if ($@) { die "can't find free ip in range $range->{'start-address'}-$range->{'end-address'}: $@" if !$noerr; } - - return $ip; - } sub del_ip { diff --git a/src/PVE/Network/SDN/Ipams/PVEPlugin.pm b/src/PVE/Network/SDN/Ipams/PVEPlugin.pm index 270fb04..651acfb 100644 --- a/src/PVE/Network/SDN/Ipams/PVEPlugin.pm +++ b/src/PVE/Network/SDN/Ipams/PVEPlugin.pm @@ -176,7 +176,7 @@ sub add_next_freeip { }); die "$@" if $@; - return "$freeip/$mask"; + return $freeip; } sub add_range_next_freeip { diff --git a/src/PVE/Network/SDN/Ipams/PhpIpamPlugin.pm b/src/PVE/Network/SDN/Ipams/PhpIpamPlugin.pm index 1b7b666..7b3168d 100644 --- a/src/PVE/Network/SDN/Ipams/PhpIpamPlugin.pm +++ b/src/PVE/Network/SDN/Ipams/PhpIpamPlugin.pm @@ -181,7 +181,7 @@ sub add_next_freeip { die "can't find free ip in subnet $cidr: $@" if !$noerr; } - return "$ip/$mask" if $ip && $mask; + return $ip; } sub del_ip { |
