From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id A36F51FF168 for ; Tue, 7 Jan 2025 15:15:11 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id C46135A27; Tue, 7 Jan 2025 15:15:00 +0100 (CET) Date: Tue, 7 Jan 2025 15:14:23 +0100 From: Gabriel Goller To: Thomas Lamprecht Message-ID: References: <20241210151130.321984-1-g.goller@proxmox.com> <20241210151130.321984-4-g.goller@proxmox.com> <5ea7a6e0-d522-4de7-9609-bb98858a5da6@proxmox.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <5ea7a6e0-d522-4de7-9609-bb98858a5da6@proxmox.com> User-Agent: NeoMutt/20241002-35-39f9a6 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.034 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pve-devel] [PATCH container v2 3/3] api: return all addresses of an interface X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Cc: Proxmox VE development discussion Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" On 10.12.2024 18:58, Thomas Lamprecht wrote: >Am 10.12.24 um 16:11 schrieb Gabriel Goller: >> Return all ip-addresses of an interface, not only the first one. Change >> return schema to resemble the 'agent/network-get-interfaces' qemu call. >> This helps us making the AgentIPView more generic and display the ip on >> both containers and vms. >> >> Signed-off-by: Gabriel Goller >> --- >> src/PVE/API2/LXC.pm | 35 +++++++++++++++++++++++++---------- >> src/PVE/LXC.pm | 7 +++++-- >> 2 files changed, 30 insertions(+), 12 deletions(-) >> >> diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm >> index 213e518a7b62..b14e88a7baf2 100644 >> --- a/src/PVE/API2/LXC.pm >> +++ b/src/PVE/API2/LXC.pm >> @@ -2546,20 +2546,35 @@ __PACKAGE__->register_method({ >> description => 'The name of the interface', >> optional => 0, >> }, >> - hwaddr => { >> + "hardware-address" => { > >Can we keep the old properties for backward compatibility and add a TODO comment >stating that they should be removed for the next major release? > >Otherwise, this breaks any tooling, automation, UI, ... that is using this API >endpoint. True, this endpoint is already merged and present in the latest version. Fixed it, thanks! >> type => 'string', >> description => 'The MAC address of the interface', >> optional => 0, >> }, >> - inet => { >> - type => 'string', >> - description => 'The IPv4 address of the interface', >> - optional => 1, >> - }, >> - inet6 => { >> - type => 'string', >> - description => 'The IPv6 address of the interface', >> - optional => 1, >> + "ip-addresses" => { >> + type => 'array', >> + description => 'All the Addresses of the interface', >> + optional => 0, >> + items => { >> + type => 'object', >> + properties => { >> + prefix => { >> + type => 'integer', >> + description => 'IP-Prefix', >> + optional => 1, >> + }, >> + "ip-address" => { >> + type => 'string', >> + description => 'IP-Address', >> + optional => 1, >> + }, >> + "ip-address-type" => { > >This is already inside a 'ip-addresses' property, so I think it would be fine to >drop prefix here. E.g., just 'ip' or just 'address' for the one above and just >'type' here. No hard feelings though, just seems a bit redundant here to me. I agree, but I wanted the schema to be the same as the qemu agent `network-get-interfaces` response so that we can have a common frontend component for vm's and container. >> + type => 'string', >> + description => 'IP-Family', >> + optional => 1, >> + }, >> + } >> + } >> }, >> } >> }, >> diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm >> index e78e36576fc3..60d92d69abcc 100644 >> --- a/src/PVE/LXC.pm >> +++ b/src/PVE/LXC.pm >> @@ -1141,10 +1141,13 @@ sub get_interfaces { >> my $res; >> for my $interface ($config->@*) { >> my $obj = { name => $interface->{ifname} }; >> + my @list = (); > >You can directly use an array reference here, i.e.: > >my $list = []; > >> for my $ip ($interface->{addr_info}->@*) { >> - $obj->{$ip->{family}} = $ip->{local} . "/" . $ip->{prefixlen}; >> + my $ip = {'ip-address-type' => $ip->{family}, 'ip-address' => $ip->{local}, 'prefix' => $ip->{prefixlen}}; >> + push(@list, $ip); > >FWIW, this can also be pushed directly, e.g., something like: > >push(@$list, { > type => $ip->{family}, > address => $ip->{local}, > prefix => $ip->{prefixlen}, >}); > Fixed this. Thanks for the review! _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel