[pve-devel] [PATCH pve-network 1/2] sdn: config generation : check if interfaces.d/sdn is sourced

Alexandre Derumier aderumier at odiso.com
Fri Jun 23 14:49:40 CEST 2023


Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 src/PVE/Network/SDN.pm | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/PVE/Network/SDN.pm b/src/PVE/Network/SDN.pm
index 1ad85e5..7ff550b 100644
--- a/src/PVE/Network/SDN.pm
+++ b/src/PVE/Network/SDN.pm
@@ -13,7 +13,7 @@ use PVE::Network::SDN::Subnets;
 
 use PVE::Tools qw(extract_param dir_glob_regex run_command);
 use PVE::Cluster qw(cfs_read_file cfs_write_file cfs_lock_file);
-
+use PVE::RESTEnvironment qw(log_warn);
 
 my $running_cfg = "sdn/.running-config";
 
@@ -208,6 +208,15 @@ sub get_local_vnets {
 
 sub generate_zone_config {
     my $raw_config = PVE::Network::SDN::Zones::generate_etc_network_config();
+    if ($raw_config) {
+	eval {
+	    my $net_cfg = PVE::INotify::read_file('interfaces', 1);
+	    my $opts = $net_cfg->{data}->{options};
+	    warn "missing 'source /etc/network/interfaces.d/sdn' directive for SDN support!\n"
+		if ! grep { $_->[1] =~ m!^source /etc/network/interfaces.d/(:?sdn|\*)! } @$opts;
+	};
+	log_warn("Failed to read network interfaces definition - $@") if $@;
+    }
     PVE::Network::SDN::Zones::write_etc_network_config($raw_config);
 }
 
-- 
2.39.2





More information about the pve-devel mailing list