]> git.proxmox.com Git - pve-network.git/commitdiff
add controller_reload
authorAlexandre Derumier <aderumier@odiso.com>
Mon, 30 Sep 2019 09:03:36 +0000 (11:03 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 17 Oct 2019 17:25:49 +0000 (19:25 +0200)
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
PVE/Network/SDN.pm
PVE/Network/SDN/FaucetPlugin.pm
PVE/Network/SDN/FrrPlugin.pm
PVE/Network/SDN/Plugin.pm

index 137f9f934a2850385247b99381ba248d14bb366b..8e96084bbdffa87778f0ec3acc1196c0bcb81a6a 100644 (file)
@@ -230,6 +230,23 @@ sub generate_controller_config {
     return $config;
 }
 
+
+sub reload_controller {
+
+    my $sdn_cfg = PVE::Cluster::cfs_read_file('sdn.cfg');
+    return if !$sdn_cfg;
+
+    foreach my $id (keys %{$sdn_cfg->{ids}}) {
+       my $plugin_config = $sdn_cfg->{ids}->{$id};
+       my $plugin = PVE::Network::SDN::Plugin->lookup($plugin_config->{type});
+       my $pd = $plugin->plugindata();
+       my $role = $pd->{role};
+       if ($role eq 'controller') {
+           $plugin->reload_controller();
+       }
+    }
+}
+
 sub write_etc_network_config {
     my ($rawconfig) = @_;
 
index 9e313c36ed515f423f7b8ce650eeae903450ca87..fe75efba8cf0a68d34b7b5ddbc2f931e1613128c 100644 (file)
@@ -98,5 +98,16 @@ sub write_controller_config {
     $writefh->close();
 }
 
+sub reload_controller {
+    my ($class) = @_;
+
+    my $conf_file = "/etc/faucet/faucet.yaml";
+    my $bin_path = "/usr/bin/faucet";
+
+    if (-e $conf_file && -e $bin_path) {
+        PVE::Tools::run_command(['systemctl', 'reload', 'faucet']);
+    }
+}
+
 1;
 
index 532247a2e177e42de8eec9cb5bf5a228f3362152..341084413a9e9d7546b72ec048a8f41cfbf86f93 100644 (file)
@@ -290,6 +290,24 @@ sub write_controller_config {
     $writefh->close();
 }
 
+sub reload_controller {
+    my ($class) = @_;
+
+    my $conf_file = "/etc/frr/frr.conf";
+    my $bin_path = "/usr/bin/vtysh";
+
+    my $err = sub {
+       my $line = shift;
+       if ($line =~ /^line (\S+)/) {
+           print "$line \n";
+       }
+    };
+
+    if (-e $conf_file && -e $bin_path) {
+       PVE::Tools::run_command([$bin_path, '-m', '-f', $conf_file], outfunc => {}, errfunc => $err);
+    }
+}
+
 1;
 
 
index 605fd0602890cdd01aa9056d9f9ff718729b81ad..0c6eaf0ef143da8f78f7c8ad27de8e409442a0d2 100644 (file)
@@ -88,6 +88,12 @@ sub write_controller_config {
     die "please implement inside plugin";
 }
 
+sub controller_reload {
+    my ($class) = @_;
+
+    die "please implement inside plugin";
+}
+
 sub on_delete_hook {
     my ($class, $sndid, $scfg) = @_;