[pve-devel] [PATCH v2 pve-network 1/5] refactor(controllers): extract read_etc_network_interfaces

Max Carrara m.carrara at proxmox.com
Mon Mar 25 14:19:56 CET 2024


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_Commit_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 at 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/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 = {};





More information about the pve-devel mailing list