From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH pve-manager 1/1] api/ui: show/return alternative interface names
Date: Mon, 14 Jul 2025 12:42:35 +0200 [thread overview]
Message-ID: <20250714104235.2107690-3-d.csapak@proxmox.com> (raw)
In-Reply-To: <20250714104235.2107690-1-d.csapak@proxmox.com>
in api listing for all interfaces, and in the GET call for an individual
interface.
If we don't show them, the user might be confused if the bridge ports
and interface names don't correlate.
enables the additional alternative names column in the network view on
the gui.
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
PVE/API2/Network.pm | 32 ++++++++++++++++++++++++++++++--
www/manager6/node/Config.js | 1 +
2 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/PVE/API2/Network.pm b/PVE/API2/Network.pm
index a8cd7649..19611cb9 100644
--- a/PVE/API2/Network.pm
+++ b/PVE/API2/Network.pm
@@ -12,6 +12,7 @@ use PVE::RESTHandler;
use PVE::RPCEnvironment;
use PVE::JSONSchema qw(get_standard_option);
use PVE::AccessControl;
+use PVE::Network;
use IO::File;
use base qw(PVE::RESTHandler);
@@ -231,6 +232,23 @@ sub json_config_properties {
return $prop;
}
+sub extract_altnames {
+ my ($iface, $altnames) = @_;
+
+ $altnames = PVE::Network::altname_mapping() if !defined($altnames);
+
+ my $iface_altnames = [];
+
+ for my $altname (keys $altnames->%*) {
+ if ($altnames->{$altname} eq $iface) {
+ push $iface_altnames->@*, $altname;
+ }
+ }
+
+ return $iface_altnames if scalar($iface_altnames->@*) > 0;
+ return undef;
+}
+
__PACKAGE__->register_method({
name => 'index',
path => '',
@@ -390,6 +408,8 @@ __PACKAGE__->register_method({
my $ifaces = $config->{ifaces};
+ my $altnames = PVE::Network::altname_mapping();
+
delete $ifaces->{lo}; # do not list the loopback device
if (my $tfilter = $param->{type}) {
@@ -424,6 +444,9 @@ __PACKAGE__->register_method({
my $type = $ifaces->{$k}->{type};
delete $ifaces->{$k}
if ($type eq 'bridge' || $type eq 'OVSBridge') && !$can_access_vnet->($k);
+
+ my $iface_altnames = extract_altnames($k, $altnames);
+ $ifaces->{$k}->{altnames} = $iface_altnames if defined($iface_altnames);
}
return PVE::RESTHandler::hash_to_array($ifaces, 'iface');
@@ -789,10 +812,15 @@ __PACKAGE__->register_method({
my $config = PVE::INotify::read_file('interfaces');
my $ifaces = $config->{ifaces};
+ my $iface = $param->{iface};
+
raise_param_exc({ iface => "interface does not exist" })
- if !$ifaces->{ $param->{iface} };
+ if !$ifaces->{$iface};
+
+ my $altnames = extract_altnames($iface);
+ $ifaces->{$iface}->{altnames} = $altnames if defined($altnames);
- return $ifaces->{ $param->{iface} };
+ return $ifaces->{$iface};
},
});
diff --git a/www/manager6/node/Config.js b/www/manager6/node/Config.js
index 4cd1671c..f6cd8749 100644
--- a/www/manager6/node/Config.js
+++ b/www/manager6/node/Config.js
@@ -190,6 +190,7 @@ Ext.define('PVE.node.Config', {
iconCls: 'fa fa-exchange',
itemId: 'network',
showApplyBtn: true,
+ showAltNames: true,
groups: ['services'],
nodename: nodename,
editOptions: {
--
2.39.5
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2025-07-14 10:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-14 10:42 [pve-devel] [PATCH manager/widget-toolkit 0/2] show altenative interface names in the web ui Dominik Csapak
2025-07-14 10:42 ` [pve-devel] [PATCH widget-toolkit 1/1] network: optionally show alternative interface names Dominik Csapak
2025-07-14 10:42 ` Dominik Csapak [this message]
2025-07-14 13:49 ` [pve-devel] [PATCH manager/widget-toolkit 0/2] show altenative interface names in the web ui Christoph Heiss
2025-07-14 13:53 ` Dominik Csapak
2025-07-14 14:31 ` Thomas Lamprecht
2025-07-15 7:41 ` Dominik Csapak
2025-07-15 8:17 ` Thomas Lamprecht
2025-07-15 8:36 ` Dominik Csapak
2025-07-15 8:54 ` Thomas Lamprecht
2025-07-15 9:00 ` Dominik Csapak
2025-07-15 9:01 ` Thomas Lamprecht
2025-07-15 9:08 ` [pve-devel] superseded: " Dominik Csapak
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=20250714104235.2107690-3-d.csapak@proxmox.com \
--to=d.csapak@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