From: Stefan Hanreich <s.hanreich@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH pve-manager v2 3/4] network-interface-pinning: add target-name parameter
Date: Thu, 24 Jul 2025 11:34:58 +0200 [thread overview]
Message-ID: <20250724093459.76397-4-s.hanreich@proxmox.com> (raw)
In-Reply-To: <20250724093459.76397-1-s.hanreich@proxmox.com>
If a specific interface is specified via the interface parameter,
users can now additionally specify a target-name. This makes it easier
for users to assign specific names to specific interfaces, according
to their preferences.
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
PVE/CLI/proxmox_network_interface_pinning.pm | 38 ++++++++++++++++----
1 file changed, 32 insertions(+), 6 deletions(-)
diff --git a/PVE/CLI/proxmox_network_interface_pinning.pm b/PVE/CLI/proxmox_network_interface_pinning.pm
index 9025cd835..357a78544 100644
--- a/PVE/CLI/proxmox_network_interface_pinning.pm
+++ b/PVE/CLI/proxmox_network_interface_pinning.pm
@@ -249,6 +249,11 @@ package PVE::CLI::proxmox_network_interface_pinning::InterfaceMapping {
use PVE::CLI::proxmox_network_interface_pinning;
use PVE::Tools;
+ sub new {
+ my ($class, $mapping) = @_;
+ bless $mapping, $class;
+ }
+
sub generate {
my ($class, $ip_links, $pinned, $prefix) = @_;
@@ -362,6 +367,12 @@ __PACKAGE__->register_method({
default => '<all>', # just for the docs.
optional => 1,
},
+ 'target-name' => {
+ description => 'Pin the interface to a specific name',
+ type => 'string',
+ pattern => 'nic\d+',
+ optional => 1,
+ },
},
},
returns => {
@@ -371,6 +382,10 @@ __PACKAGE__->register_method({
my ($params) = @_;
my $iface = $params->{interface}; # undef means all.
+ my $target_name = $params->{'target-name'};
+
+ die "target-name can only be set, if interface is set as well!\n"
+ if $params->{'target-name'} && !$params->{interface};
if (-t STDOUT) {
my $target = defined($iface) ? "the interface '$iface'" : 'all interfaces';
@@ -402,12 +417,23 @@ __PACKAGE__->register_method({
}
}
- my $mapping =
- PVE::CLI::proxmox_network_interface_pinning::InterfaceMapping->generate(
- $ip_links,
- $pinned,
- $prefix,
- );
+ my $mapping;
+
+ if ($target_name) {
+ die "target-name already exists as link or pin!\n"
+ if $ip_links->{$target_name} || grep { $target_name eq $_ } values $pinned->%*;
+
+ $mapping = PVE::CLI::proxmox_network_interface_pinning::InterfaceMapping->new({
+ $iface => $target_name,
+ });
+ } else {
+ $mapping =
+ PVE::CLI::proxmox_network_interface_pinning::InterfaceMapping->generate(
+ $ip_links,
+ $pinned,
+ $prefix,
+ );
+ }
if (!$mapping->%*) {
print "Nothing to do, aborting.\n";
--
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-24 9:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-24 9:34 [pve-devel] [PATCH manager v2 0/4] improvements to proxmox-network-interface-pinning Stefan Hanreich
2025-07-24 9:34 ` [pve-devel] [PATCH pve-manager v2 1/4] network-interface-pinning: use ifindex as order for pinning Stefan Hanreich
2025-07-24 9:34 ` [pve-devel] [PATCH pve-manager v2 2/4] network-interface-pinning: improve printing mapping Stefan Hanreich
2025-07-24 9:34 ` Stefan Hanreich [this message]
2025-07-24 9:34 ` [pve-devel] [PATCH pve-manager v2 4/4] network-interface-pinning: add if prefix to list of allowed prefixes Stefan Hanreich
2025-07-29 7:38 ` [pve-devel] applied: [PATCH manager v2 0/4] improvements to proxmox-network-interface-pinning Thomas Lamprecht
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=20250724093459.76397-4-s.hanreich@proxmox.com \
--to=s.hanreich@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