From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <m.carrara@proxmox.com>
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 2FF6ABB765
 for <pve-devel@lists.proxmox.com>; Mon, 25 Mar 2024 14:19:59 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 0E1F34BB5
 for <pve-devel@lists.proxmox.com>; Mon, 25 Mar 2024 14:19:59 +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 <pve-devel@lists.proxmox.com>; Mon, 25 Mar 2024 14:19:57 +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 41AC341F11
 for <pve-devel@lists.proxmox.com>; Mon, 25 Mar 2024 14:19:57 +0100 (CET)
Content-Type: text/plain; charset=UTF-8
Date: Mon, 25 Mar 2024 14:19:56 +0100
Message-Id: <D02V0X3ZSQLV.2ADYTDPJKK8MM@proxmox.com>
From: "Max Carrara" <m.carrara@proxmox.com>
To: "Proxmox VE development discussion" <pve-devel@lists.proxmox.com>
Mime-Version: 1.0
Content-Transfer-Encoding: quoted-printable
X-Mailer: aerc 0.17.0-72-g6a84f1331f1c
References: <20240307151319.301984-2-s.lendl@proxmox.com>
 <20240307151319.301984-3-s.lendl@proxmox.com>
In-Reply-To: <20240307151319.301984-3-s.lendl@proxmox.com>
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.021 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
 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more
 information. [controllers.pm, proxmox.com]
Subject: Re: [pve-devel] [PATCH v2 pve-network 1/5] 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 <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Mon, 25 Mar 2024 13:19:59 -0000

Should just be "controllers: [...]" as per our commit guidelines [0],
but this can honestly be changed while applying.

Otherwise LGTM!

[0]: https://pve.proxmox.com/wiki/Developer_Documentation#Commits_and_Commi=
t_Messages

On Thu Mar 7, 2024 at 4:13 PM CET, Stefan Lendl wrote:
> to allow mocking local fs access
>
> Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
> ---
>  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/Con=
trollers.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_controller=
s_ids($cfg) ];
>  }
> =20
> +sub read_etc_network_interfaces {
> +    # read main config for physical interfaces
> +    my $current_config_file =3D "/etc/network/interfaces";
> +    my $fh =3D IO::File->new($current_config_file) or die "failed to ope=
n $current_config_file - $!\n";
> +    my $interfaces_config =3D PVE::INotify::read_etc_network_interfaces(=
$current_config_file, $fh);
> +    $fh->close();
> +
> +    return $interfaces_config;
> +}
> +
>  sub generate_controller_config {
> =20
>      my $cfg =3D PVE::Network::SDN::running_config();
> @@ -79,11 +89,7 @@ sub generate_controller_config {
> =20
>      return if !$vnet_cfg && !$zone_cfg && !$controller_cfg;
> =20
> -    # read main config for physical interfaces
> -    my $current_config_file =3D "/etc/network/interfaces";
> -    my $fh =3D IO::File->new($current_config_file) or die "failed to ope=
n $current_config_file - $!\n";
> -    my $interfaces_config =3D PVE::INotify::read_etc_network_interfaces(=
$current_config_file, $fh);
> -    $fh->close();
> +    my $interfaces_config =3D read_etc_network_interfaces();
> =20
>      # check uplinks
>      my $uplinks =3D {};