summaryrefslogtreecommitdiff
path: root/src/PVE/Network/SDN/Controllers/IsisPlugin.pm
diff options
context:
space:
mode:
authorAlexandre Derumier <aderumier@odiso.com>2023-09-13 13:38:45 +0200
committerFabian Grünbichler <f.gruenbichler@proxmox.com>2023-10-25 12:50:41 +0200
commit9ce18f80bc9deece323a52e02d92e5fe978698f5 (patch)
tree82d2026bec1002352453aceb4ad8b9bee9589ea4 /src/PVE/Network/SDN/Controllers/IsisPlugin.pm
parentced9392063d1cd2ecd93a2e41f5bf00fe3514665 (diff)
controllers: add isis router plugin
Diffstat (limited to 'src/PVE/Network/SDN/Controllers/IsisPlugin.pm')
-rw-r--r--src/PVE/Network/SDN/Controllers/IsisPlugin.pm123
1 files changed, 123 insertions, 0 deletions
diff --git a/src/PVE/Network/SDN/Controllers/IsisPlugin.pm b/src/PVE/Network/SDN/Controllers/IsisPlugin.pm
new file mode 100644
index 0000000..afea82e
--- /dev/null
+++ b/src/PVE/Network/SDN/Controllers/IsisPlugin.pm
@@ -0,0 +1,123 @@
+package PVE::Network::SDN::Controllers::IsisPlugin;
+
+use strict;
+use warnings;
+
+use PVE::INotify;
+use PVE::JSONSchema qw(get_standard_option);
+use PVE::Tools qw(run_command file_set_contents file_get_contents);
+
+use PVE::Network::SDN::Controllers::Plugin;
+use PVE::Network::SDN::Zones::Plugin;
+use Net::IP;
+
+use base('PVE::Network::SDN::Controllers::Plugin');
+
+sub type {
+ return 'isis';
+}
+
+sub properties {
+ return {
+ 'isis-domain' => {
+ description => "ISIS domain.",
+ type => 'string'
+ },
+ 'isis-ifaces' => {
+ description => "ISIS interface.",
+ type => 'string', format => 'pve-iface-list',
+ },
+ 'isis-net' => {
+ description => "ISIS network entity title.",
+ type => 'string'
+ },
+ };
+}
+
+sub options {
+ return {
+ 'isis-domain' => { optional => 0 },
+ 'isis-net' => { optional => 0 },
+ 'isis-ifaces' => { optional => 0 },
+ 'node' => { optional => 0 },
+ 'loopback' => { optional => 1 },
+ };
+}
+
+# Plugin implementation
+sub generate_controller_config {
+ my ($class, $plugin_config, $controller, $id, $uplinks, $config) = @_;
+
+ my $isis_ifaces = $plugin_config->{'isis-ifaces'};
+ my $isis_net = $plugin_config->{'isis-net'};
+ my $isis_domain = $plugin_config->{'isis-domain'};
+ my $local_node = PVE::INotify::nodename();
+
+ return if !$isis_ifaces || !$isis_net || !$isis_domain;
+ return if $local_node ne $plugin_config->{node};
+
+ my @router_config = (
+ "net $isis_net",
+ "redistribute ipv4 connected level-1",
+ "redistribute ipv6 connected level-1",
+ "log-adjacency-changes",
+ );
+
+ push(@{$config->{frr}->{router}->{"isis $isis_domain"}}, @router_config);
+
+ my @iface_config = (
+ "ip router isis $isis_domain"
+ );
+
+ my @ifaces = PVE::Tools::split_list($isis_ifaces);
+ for my $iface (sort @ifaces) {
+ push(@{$config->{frr_interfaces}->{$iface}}, @iface_config);
+ }
+
+ return $config;
+}
+
+sub generate_controller_zone_config {
+ my ($class, $plugin_config, $controller, $controller_cfg, $id, $uplinks, $config) = @_;
+
+}
+
+sub on_delete_hook {
+ my ($class, $controllerid, $zone_cfg) = @_;
+
+}
+
+sub on_update_hook {
+ my ($class, $controllerid, $controller_cfg) = @_;
+
+ # we can only have 1 bgp controller by node
+ my $local_node = PVE::INotify::nodename();
+ my $controllernb = 0;
+ foreach my $id (keys %{$controller_cfg->{ids}}) {
+ next if $id eq $controllerid;
+ my $controller = $controller_cfg->{ids}->{$id};
+ next if $controller->{type} ne "isis";
+ next if $controller->{node} ne $local_node;
+ $controllernb++;
+ die "only 1 bgp or isis controller can be defined" if $controllernb > 1;
+ }
+}
+
+sub generate_controller_rawconfig {
+ my ($class, $plugin_config, $config) = @_;
+ return "";
+}
+
+sub write_controller_config {
+ my ($class, $plugin_config, $config) = @_;
+ return;
+}
+
+sub reload_controller {
+ my ($class) = @_;
+ return;
+}
+
+1;
+
+