summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/PVE/API2/Network/SDN.pm15
-rw-r--r--src/PVE/Network/SDN.pm21
2 files changed, 33 insertions, 3 deletions
diff --git a/src/PVE/API2/Network/SDN.pm b/src/PVE/API2/Network/SDN.pm
index b514803..0824410 100644
--- a/src/PVE/API2/Network/SDN.pm
+++ b/src/PVE/API2/Network/SDN.pm
@@ -83,13 +83,18 @@ __PACKAGE__->register_method({
});
my $create_reload_network_worker = sub {
- my ($nodename) = @_;
+ my ($nodename, $skip_frr) = @_;
+
+ my @command = ('pvesh', 'set', "/nodes/$nodename/network");
+ if ($skip_frr) {
+ push(@command, '--skip_frr');
+ }
# FIXME: how to proxy to final node ?
my $upid;
print "$nodename: reloading network config\n";
run_command(
- ['pvesh', 'set', "/nodes/$nodename/network"],
+ \@command,
outfunc => sub {
my $line = shift;
if ($line =~ /["']?(UPID:[^\s"']+)["']?$/) {
@@ -124,14 +129,18 @@ __PACKAGE__->register_method({
my $rpcenv = PVE::RPCEnvironment::get();
my $authuser = $rpcenv->get_user();
+ my $previous_config_has_frr = PVE::Network::SDN::running_config_has_frr();
PVE::Network::SDN::commit_config();
+ my $new_config_has_frr = PVE::Network::SDN::running_config_has_frr();
+ my $skip_frr = !($previous_config_has_frr || $new_config_has_frr);
+
my $code = sub {
$rpcenv->{type} = 'priv'; # to start tasks in background
PVE::Cluster::check_cfs_quorum();
my $nodelist = PVE::Cluster::get_nodelist();
for my $node (@$nodelist) {
- my $pid = eval { $create_reload_network_worker->($node) };
+ my $pid = eval { $create_reload_network_worker->($node, $skip_frr) };
warn $@ if $@;
}
diff --git a/src/PVE/Network/SDN.pm b/src/PVE/Network/SDN.pm
index ce4b41e..b321013 100644
--- a/src/PVE/Network/SDN.pm
+++ b/src/PVE/Network/SDN.pm
@@ -84,6 +84,27 @@ sub running_config {
return cfs_read_file($running_cfg);
}
+=head3 running_config_has_frr(\%running_config)
+
+Determines whether C<\%running_config> contains any entities that generate an
+FRR configuration. This is used by pve-manager to determine whether a rewrite of
+the FRR configuration is required or not.
+
+If C<\%running_config> is not provided, it will query the current running
+configuration and then evaluate it.
+
+=cut
+
+sub running_config_has_frr {
+ my $running_config = PVE::Network::SDN::running_config();
+
+ # both can be empty if the SDN configuration was never applied
+ my $controllers = $running_config->{controllers}->{ids} // {};
+ my $fabrics = $running_config->{fabrics}->{ids} // {};
+
+ return %$controllers || %$fabrics;
+}
+
sub pending_config {
my ($running_cfg, $cfg, $type) = @_;