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 <g.gol...@proxmox.com> --- 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" => { 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" => { + 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 = (); 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); } - $obj->{hwaddr} = $interface->{address}; + $obj->{'ip-addresses'} = \@list; + $obj->{'hardware-address'} = $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