From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 038BBBF0B4 for ; Wed, 3 Jan 2024 16:45:39 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2FEE134F6D for ; Wed, 3 Jan 2024 16:45:08 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Wed, 3 Jan 2024 16:45:06 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id E68BB48CDB for ; Wed, 3 Jan 2024 16:45:05 +0100 (CET) From: Stefan Lendl To: pve-devel@lists.proxmox.com Date: Wed, 3 Jan 2024 16:37:52 +0100 Message-ID: <20240103153753.407079-8-s.lendl@proxmox.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240103153753.407079-3-s.lendl@proxmox.com> References: <20240103153753.407079-3-s.lendl@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.039 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 T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH pve-network 5/8] refactor(controllers): extract read_etc_network_interfaces 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: , X-List-Received-Date: Wed, 03 Jan 2024 15:45:39 -0000 to allow mocking local fs access. Signed-off-by: Stefan Lendl --- src/PVE/Network/SDN/Controllers.pm | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/PVE/Network/SDN/Controllers.pm b/src/PVE/Network/SDN/Controllers.pm index 167d3ea..fd7ad54 100644 --- a/src/PVE/Network/SDN/Controllers.pm +++ b/src/PVE/Network/SDN/Controllers.pm @@ -70,6 +70,16 @@ sub complete_sdn_controller { return $cmdname eq 'add' ? [] : [ PVE::Network::SDN::sdn_controllers_ids($cfg) ]; } +sub read_etc_network_interfaces { + # read main config for physical interfaces + my $current_config_file = "/etc/network/interfaces"; + my $fh = IO::File->new($current_config_file) or die "failed to open $current_config_file - $!\n"; + my $interfaces_config = PVE::INotify::read_etc_network_interfaces($current_config_file, $fh); + $fh->close(); + + return $interfaces_config; +} + sub generate_controller_config { my $cfg = PVE::Network::SDN::running_config(); @@ -79,11 +89,7 @@ sub generate_controller_config { return if !$vnet_cfg && !$zone_cfg && !$controller_cfg; - # read main config for physical interfaces - my $current_config_file = "/etc/network/interfaces"; - my $fh = IO::File->new($current_config_file) or die "failed to open $current_config_file - $!\n"; - my $interfaces_config = PVE::INotify::read_etc_network_interfaces($current_config_file, $fh); - $fh->close(); + my $interfaces_config = read_etc_network_interfaces(); # check uplinks my $uplinks = {}; -- 2.42.0