[pve-devel] [PATCH v2 pve-manager] api2: network : reload sdn controller generic

Alexandre Derumier aderumier at odiso.com
Mon Sep 30 11:34:53 CEST 2019


use config generation && reloading from plugins
(require my last pve-network patch serie)

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/API2/Network.pm | 25 +++++--------------------
 1 file changed, 5 insertions(+), 20 deletions(-)

diff --git a/PVE/API2/Network.pm b/PVE/API2/Network.pm
index fa605ba7..194b300a 100644
--- a/PVE/API2/Network.pm
+++ b/PVE/API2/Network.pm
@@ -554,22 +554,12 @@ __PACKAGE__->register_method({
 	my $new_config_file = "/etc/network/interfaces.new";
 
 	die "you need ifupdown2 to reload networking\n" if !-e '/usr/share/ifupdown2';
-	die "ifupdown2 reload is not compatible if openvswitch currently" if -x '/usr/bin/ovs-vsctl';
+	warn "openvswitch config can't be reloaded currently. Please reboot to apply ovs changes" if -x '/usr/bin/ovs-vsctl';
 
 	my $worker = sub {
 
 	    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 $err = sub {
 		my $line = shift;
 		if ($line =~ /(warning|error): (\S+):/) {
@@ -578,15 +568,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::generate_controller_config();
+		PVE::Network::SDN::write_controller_config($controller_config) if ($controller_config);
+		PVE::Network::SDN::reload_controller();
 	    }
 	};
 	return $rpcenv->fork_worker('srvreload', 'networking', $authuser, $worker);
-- 
2.20.1




More information about the pve-devel mailing list