From: Gabriel Goller <g.goller@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH container v3 3/3] api: return all addresses of an interface
Date: Wed, 8 Jan 2025 10:33:14 +0100 [thread overview]
Message-ID: <20250108093314.33490-4-g.goller@proxmox.com> (raw)
In-Reply-To: <20250108093314.33490-1-g.goller@proxmox.com>
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 <jcdra1@gmail.com>
Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
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
prev parent reply other threads:[~2025-01-08 9:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-08 9:33 [pve-devel] [PATCH container/manager v3 0/3] Show container ip in summary and network tab Gabriel Goller
2025-01-08 9:33 ` [pve-devel] [PATCH manager v3 1/3] lxc: show dynamically assigned IPs in " Gabriel Goller
2025-01-08 9:33 ` [pve-devel] [PATCH manager v3 2/3] guest: refactor and reuse AgentIPView for containers Gabriel Goller
2025-01-08 14:28 ` Gabriel Goller
2025-01-08 9:33 ` Gabriel Goller [this message]
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=20250108093314.33490-4-g.goller@proxmox.com \
--to=g.goller@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/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