From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id AF95C1FF16F for ; Tue, 14 Oct 2025 15:22:37 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 756AF3EC1; Tue, 14 Oct 2025 15:22:23 +0200 (CEST) From: Christoph Heiss To: pve-devel@lists.proxmox.com Date: Tue, 14 Oct 2025 15:21:55 +0200 Message-ID: <20251014132207.1171073-11-c.heiss@proxmox.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251014132207.1171073-1-c.heiss@proxmox.com> References: <20251014132207.1171073-1-c.heiss@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1760448096040 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.038 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 Subject: [pve-devel] [PATCH installer 10/14] post-hook: add network interface name and pinning status 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" Adds a new `name` and `is-pinned` attribute to each reported network interface in the post-hook data. Also increments the minor schema version by one, as it is a backwards-compatible change. Signed-off-by: Christoph Heiss --- proxmox-post-hook/src/main.rs | 39 +++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/proxmox-post-hook/src/main.rs b/proxmox-post-hook/src/main.rs index 0a9e661..ce64533 100644 --- a/proxmox-post-hook/src/main.rs +++ b/proxmox-post-hook/src/main.rs @@ -76,6 +76,8 @@ struct DiskInfo { #[derive(Serialize)] #[serde(rename_all = "kebab-case")] struct NetworkInterfaceInfo { + /// Name of the interface + name: String, /// MAC address of the interface mac: String, /// (Designated) IP address of the interface @@ -85,6 +87,10 @@ struct NetworkInterfaceInfo { /// installation. #[serde(skip_serializing_if = "bool_is_false")] is_management: bool, + /// Set to true if the network interface name was pinned based on the MAC + /// address during the installation. + #[serde(skip_serializing_if = "bool_is_false")] + is_pinned: bool, /// Properties about the device as given by udev. udev_properties: UdevProperties, } @@ -151,7 +157,7 @@ struct PostHookInfoSchema { } impl PostHookInfoSchema { - const SCHEMA_VERSION: &str = "1.1"; + const SCHEMA_VERSION: &str = "1.2"; } impl Default for PostHookInfoSchema { @@ -386,23 +392,24 @@ impl PostHookInfo { })? .clone(); - if config.mngmt_nic == nic.name { + let is_pinned = config.network_interface_pin_map.contains_key(&nic.mac); + let ifname = config + .network_interface_pin_map + .get(&nic.mac) + .unwrap_or(&nic.name); + + let is_management = config.mngmt_nic == *ifname; + + anyhow::Ok(NetworkInterfaceInfo { + name: ifname.clone(), + mac: nic.mac.clone(), // Use the actual IP address from the low-level install config, as the runtime info // contains the original IP address from DHCP. - anyhow::Ok(NetworkInterfaceInfo { - mac: nic.mac.clone(), - address: Some(config.cidr.clone()), - is_management: true, - udev_properties, - }) - } else { - anyhow::Ok(NetworkInterfaceInfo { - mac: nic.mac.clone(), - address: None, - is_management: false, - udev_properties, - }) - } + address: is_management.then_some(config.cidr.clone()), + is_management, + is_pinned, + udev_properties, + }) }) .collect()) } -- 2.51.0 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel