public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Alexandre Derumier <aderumier@odiso.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH pve-network 2/3] controllers: add generate_controller_rawconfig
Date: Wed,  9 Dec 2020 16:11:18 +0100	[thread overview]
Message-ID: <20201209151119.3620405-3-aderumier@odiso.com> (raw)
In-Reply-To: <20201209151119.3620405-1-aderumier@odiso.com>

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
---
 PVE/Network/SDN/Controllers.pm            | 19 ++++++++++++++++++-
 PVE/Network/SDN/Controllers/BgpPlugin.pm  |  5 +++++
 PVE/Network/SDN/Controllers/EvpnPlugin.pm | 10 +++++++++-
 PVE/Network/SDN/Controllers/Plugin.pm     |  6 ++++++
 4 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/PVE/Network/SDN/Controllers.pm b/PVE/Network/SDN/Controllers.pm
index 9937755..ba67d75 100644
--- a/PVE/Network/SDN/Controllers.pm
+++ b/PVE/Network/SDN/Controllers.pm
@@ -147,10 +147,27 @@ sub reload_controller {
     }
 }
 
+sub generate_controller_rawconfig {
+    my ($config) = @_;
+
+    my $cfg = PVE::Network::SDN::config();
+    my $controller_cfg = $cfg->{controllers};
+    return if !$controller_cfg;
+
+    my $rawconfig = "";
+    foreach my $id (keys %{$controller_cfg->{ids}}) {
+	my $plugin_config = $controller_cfg->{ids}->{$id};
+	my $plugin = PVE::Network::SDN::Controllers::Plugin->lookup($plugin_config->{type});
+	$rawconfig .= $plugin->generate_controller_rawconfig($plugin_config, $config);
+    }
+    return $rawconfig;
+}
+
 sub write_controller_config {
     my ($config) = @_;
 
-    my $controller_cfg = PVE::Cluster::cfs_read_file('sdn/controllers.cfg');
+    my $cfg = PVE::Network::SDN::config();
+    my $controller_cfg = $cfg->{controllers};
     return if !$controller_cfg;
 
     foreach my $id (keys %{$controller_cfg->{ids}}) {
diff --git a/PVE/Network/SDN/Controllers/BgpPlugin.pm b/PVE/Network/SDN/Controllers/BgpPlugin.pm
index ccc06a8..e5d8490 100644
--- a/PVE/Network/SDN/Controllers/BgpPlugin.pm
+++ b/PVE/Network/SDN/Controllers/BgpPlugin.pm
@@ -138,6 +138,11 @@ sub on_update_hook {
     }
 }
 
+sub generate_controller_rawconfig {
+    my ($class, $plugin_config, $config) = @_;
+    return "";
+}
+
 sub write_controller_config {
     my ($class, $plugin_config, $config) = @_;
     return;
diff --git a/PVE/Network/SDN/Controllers/EvpnPlugin.pm b/PVE/Network/SDN/Controllers/EvpnPlugin.pm
index 6927921..55828ef 100644
--- a/PVE/Network/SDN/Controllers/EvpnPlugin.pm
+++ b/PVE/Network/SDN/Controllers/EvpnPlugin.pm
@@ -280,7 +280,7 @@ sub generate_frr_recurse{
     }
 }
 
-sub write_controller_config {
+sub generate_controller_rawconfig {
     my ($class, $plugin_config, $config) = @_;
 
     my $nodename = PVE::INotify::nodename();
@@ -311,6 +311,14 @@ sub write_controller_config {
 
     my $rawconfig = join("\n", @{$final_config});
 
+    return if !$rawconfig;
+    return $rawconfig;
+}
+
+sub write_controller_config {
+    my ($class, $plugin_config, $config) = @_;
+
+    my $rawconfig = $class->generate_controller_rawconfig($plugin_config, $config);
     return if !$rawconfig;
     return if !-d "/etc/frr";
 
diff --git a/PVE/Network/SDN/Controllers/Plugin.pm b/PVE/Network/SDN/Controllers/Plugin.pm
index 0c92b17..8b5bd4f 100644
--- a/PVE/Network/SDN/Controllers/Plugin.pm
+++ b/PVE/Network/SDN/Controllers/Plugin.pm
@@ -87,6 +87,12 @@ sub generate_controller_vnet_config {
 
 }
 
+sub generate_controller_rawconfig {
+    my ($class, $plugin_config, $config) = @_;
+
+    die "please implement inside plugin";
+}
+
 sub write_controller_config {
     my ($class, $plugin_config, $config) = @_;
 
-- 
2.20.1




  parent reply	other threads:[~2020-12-09 15:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-09 15:11 [pve-devel] [PATCH pve-network 0/3] add zones/controllers tests Alexandre Derumier
2020-12-09 15:11 ` [pve-devel] [PATCH pve-network 1/3] zones: add bridge helpers Alexandre Derumier
2020-12-09 15:11 ` Alexandre Derumier [this message]
2020-12-09 15:11 ` [pve-devel] [PATCH pve-network 3/3] add zones && controllers unit tests Alexandre Derumier
2020-12-18 17:05 ` [pve-devel] applied: Re: [PATCH pve-network 0/3] add zones/controllers tests Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201209151119.3620405-3-aderumier@odiso.com \
    --to=aderumier@odiso.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal