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 7E6801FF15C for ; Wed, 8 Jan 2025 10:33:37 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E9AE014906; Wed, 8 Jan 2025 10:33:21 +0100 (CET) From: Gabriel Goller To: pve-devel@lists.proxmox.com Date: Wed, 8 Jan 2025 10:33:14 +0100 Message-Id: <20250108093314.33490-4-g.goller@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250108093314.33490-1-g.goller@proxmox.com> References: <20250108093314.33490-1-g.goller@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.032 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 SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [lxc.pm] Subject: [pve-devel] [PATCH container v3 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" Return all ip-addresses of an interface, not only the first one. Change return schema to resemble the 'agent/network-get-interfaces' qemu call reponse. This helps us making the AgentIPView more generic and display the ip on both containers and vms. Preserve old attributes so that we remain backwards-compatible. These should be removed in the next version. Fixes: #5339 Cc: Johannes Draaijer Signed-off-by: Gabriel Goller --- src/PVE/API2/LXC.pm | 37 +++++++++++++++++++++++++++++++++++-- src/PVE/LXC.pm | 15 +++++++++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm index 213e518a7b62..57c7b42405dd 100644 --- a/src/PVE/API2/LXC.pm +++ b/src/PVE/API2/LXC.pm @@ -2546,20 +2546,53 @@ __PACKAGE__->register_method({ description => 'The name of the interface', optional => 0, }, + # TODO: deprecate on next major release hwaddr => { type => 'string', description => 'The MAC address of the interface', optional => 0, }, + "hardware-address" => { + type => 'string', + description => 'The MAC address of the interface', + optional => 0, + }, + # TODO: deprecate on next major release inet => { type => 'string', description => 'The IPv4 address of the interface', - optional => 1, + optional => 1 }, + # TODO: deprecate on next major release inet6 => { type => 'string', description => 'The IPv6 address of the interface', - optional => 1, + optional => 1 + }, + "ip-addresses" => { + type => 'array', + description => '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" => { + type => 'string', + description => 'IP-Family', + optional => 1, + }, + } + } }, } }, diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm index e78e36576fc3..7c71a49f7723 100644 --- a/src/PVE/LXC.pm +++ b/src/PVE/LXC.pm @@ -1141,10 +1141,25 @@ sub get_interfaces { my $res; for my $interface ($config->@*) { my $obj = { name => $interface->{ifname} }; + my $list = []; for my $ip ($interface->{addr_info}->@*) { + # TODO: remove on next major release $obj->{$ip->{family}} = $ip->{local} . "/" . $ip->{prefixlen}; + + push( + @$list, { + 'ip-address-type' => $ip->{family}, + 'ip-address' => $ip->{local}, + 'prefix' => $ip->{prefixlen} + } + ); } + $obj->{'ip-addresses'} = $list; + $obj->{'hardware-address'} = $interface->{address}; + + # TODO: remove on next major release $obj->{hwaddr} = $interface->{address}; + push @$res, $obj } -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel