[pve-devel] [PATCH v3 pve-manager 2/4] api2 : reload : use zones/controllers sdn plugins

Alexandre Derumier aderumier at odiso.com
Tue Nov 26 15:20:10 CET 2019


---
 PVE/API2/Network.pm | 25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)

diff --git a/PVE/API2/Network.pm b/PVE/API2/Network.pm
index 60178c86..2d201c0e 100644
--- a/PVE/API2/Network.pm
+++ b/PVE/API2/Network.pm
@@ -18,7 +18,8 @@ use base qw(PVE::RESTHandler);
 
 my $have_sdn;
 eval {
-    require PVE::API2::Network::SDN;
+    require PVE::Network::SDN::Zones;
+    require PVE::Network::SDN::Controllers;
     $have_sdn = 1;
 };
 
@@ -578,16 +579,11 @@ __PACKAGE__->register_method({
 
 	    rename($new_config_file, $current_config_file) if -e $new_config_file;
 
-	    my $frr_config;
 	    if ($have_sdn) {
-		my $network_config = PVE::Network::SDN::generate_etc_network_config();
-		PVE::Network::SDN::write_etc_network_config($network_config);
-
-		$frr_config = PVE::Network::SDN::generate_frr_config();
-		PVE::Network::SDN::write_frr_config($frr_config) if $frr_config;
+		my $network_sdn_config = PVE::Network::SDN::Zones::generate_etc_network_config();
+		PVE::Network::SDN::Zones::write_etc_network_config($network_sdn_config);
 	    }
 
-
 	    my $err = sub {
 		my $line = shift;
 		if ($line =~ /(warning|error): (\S+):/) {
@@ -596,15 +592,10 @@ __PACKAGE__->register_method({
 	    };
 	    PVE::Tools::run_command(['ifreload', '-a'], errfunc => $err);
 
-	    my $err_frr = sub {
-		my $line = shift;
-		if ($line =~ /^line (\S+)/) {
-		    print "$line \n";
-		}
-	    };
-
-	    if ($frr_config && -e "/usr/bin/vtysh") {
-		PVE::Tools::run_command(['/usr/bin/vtysh', '-m', '-f', '/etc/frr/frr.conf'], outfunc => {}, errfunc => $err_frr);
+	    if ($have_sdn) {
+		my $controller_config = PVE::Network::SDN::Controllers::generate_controller_config();
+		PVE::Network::SDN::Controllers::write_controller_config($controller_config) if ($controller_config);
+		PVE::Network::SDN::Controllers::reload_controller();
 	    }
 	};
 	return $rpcenv->fork_worker('srvreload', 'networking', $authuser, $worker);
-- 
2.20.1




More information about the pve-devel mailing list