diff options
Diffstat (limited to 'src/PVE/Network/SDN/Controllers')
| -rw-r--r-- | src/PVE/Network/SDN/Controllers/EvpnPlugin.pm | 28 | ||||
| -rw-r--r-- | src/PVE/Network/SDN/Controllers/IsisPlugin.pm | 123 | ||||
| -rw-r--r-- | src/PVE/Network/SDN/Controllers/Makefile | 2 |
3 files changed, 148 insertions, 5 deletions
diff --git a/src/PVE/Network/SDN/Controllers/EvpnPlugin.pm b/src/PVE/Network/SDN/Controllers/EvpnPlugin.pm index f1dd20f..3ac7d7e 100644 --- a/src/PVE/Network/SDN/Controllers/EvpnPlugin.pm +++ b/src/PVE/Network/SDN/Controllers/EvpnPlugin.pm @@ -53,11 +53,15 @@ sub generate_controller_config { my $loopback = undef; my $autortas = undef; my $bgprouter = find_bgp_controller($local_node, $controller_cfg); + my $isisrouter = find_isis_controller($local_node, $controller_cfg); + if ($bgprouter) { $ebgp = 1 if $plugin_config->{'asn'} ne $bgprouter->{asn}; $loopback = $bgprouter->{loopback} if $bgprouter->{loopback}; $asn = $bgprouter->{asn} if $bgprouter->{asn}; $autortas = $plugin_config->{'asn'} if $ebgp; + } elsif ($isisrouter) { + $loopback = $isisrouter->{loopback} if $isisrouter->{loopback}; } return if !$asn; @@ -86,10 +90,8 @@ sub generate_controller_config { push @controller_config, "neighbor VTEP remote-as $remoteas"; push @controller_config, "neighbor VTEP bfd"; - if($ebgp && $loopback) { - push @controller_config, "neighbor VTEP ebgp-multihop 10"; - push @controller_config, "neighbor VTEP update-source $loopback"; - } + push @controller_config, "neighbor VTEP ebgp-multihop 10" if $ebgp && $loopback; + push @controller_config, "neighbor VTEP update-source $loopback" if $loopback; # VTEP peers foreach my $address (@peers) { @@ -136,11 +138,15 @@ sub generate_controller_zone_config { my $loopback = undef; my $autortas = undef; my $bgprouter = find_bgp_controller($local_node, $controller_cfg); + my $isisrouter = find_isis_controller($local_node, $controller_cfg); + if($bgprouter) { $ebgp = 1 if $controller->{'asn'} ne $bgprouter->{asn}; $loopback = $bgprouter->{loopback} if $bgprouter->{loopback}; $asn = $bgprouter->{asn} if $bgprouter->{asn}; $autortas = $controller->{'asn'} if $ebgp; + } elsif ($isisrouter) { + $loopback = $isisrouter->{loopback} if $isisrouter->{loopback}; } return if !$vrf || !$vrfvxlan || !$asn; @@ -306,6 +312,20 @@ sub find_bgp_controller { return $res; } +sub find_isis_controller { + my ($nodename, $controller_cfg) = @_; + + my $res = undef; + foreach my $id (keys %{$controller_cfg->{ids}}) { + my $controller = $controller_cfg->{ids}->{$id}; + next if $controller->{type} ne 'isis'; + next if $controller->{node} ne $nodename; + $res = $controller; + last; + } + return $res; +} + sub generate_frr_recurse{ my ($final_config, $content, $parentkey, $level) = @_; 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; + + diff --git a/src/PVE/Network/SDN/Controllers/Makefile b/src/PVE/Network/SDN/Controllers/Makefile index 11686a3..fd9f881 100644 --- a/src/PVE/Network/SDN/Controllers/Makefile +++ b/src/PVE/Network/SDN/Controllers/Makefile @@ -1,4 +1,4 @@ -SOURCES=Plugin.pm FaucetPlugin.pm EvpnPlugin.pm BgpPlugin.pm +SOURCES=Plugin.pm FaucetPlugin.pm EvpnPlugin.pm BgpPlugin.pm IsisPlugin.pm PERL5DIR=${DESTDIR}/usr/share/perl5 |
