diff options
| author | Stefan Lendl <s.lendl@proxmox.com> | 2024-04-02 13:07:38 +0200 |
|---|---|---|
| committer | Thomas Lamprecht <t.lamprecht@proxmox.com> | 2024-04-04 16:50:08 +0200 |
| commit | d06ee817a734ccc325e9b502fac4b8647b93ffe3 (patch) | |
| tree | ff6c3245b9a64e63deaef3fd1f15e99e0222e432 | |
| parent | 2d0cb1a3a278329e5d4c917ba4da7215e4a17dc8 (diff) | |
controllers: extract read_etc_network_interfaces
to allow mocking local fs access
Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
Reviewed-by: Max Carrara <m.carrara@proxmox.com>
Tested-by: Max Carrara <m.carrara@proxmox.com>
Tested-By: Stefan Hanreich <s.hanreich@proxmox.com>
| -rw-r--r-- | src/PVE/Network/SDN/Controllers.pm | 16 |
1 files 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 = {}; |
