]> git.proxmox.com Git - pve-network.git/commitdiff
write configuration to networks.cfg.new
authorAlexandre Derumier <aderumier@odiso.com>
Mon, 6 May 2019 12:47:13 +0000 (14:47 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 8 May 2019 06:02:52 +0000 (08:02 +0200)
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
PVE/Network/Network.pm
PVE/Network/Network/Plugin.pm

index 8bd272f11f55cc15fc705478bc45e883b49ae504..ee0b9733ce5c6ef7eb4e54bd7e66de7bb62c4f65 100644 (file)
@@ -27,20 +27,21 @@ sub network_config {
 }
 
 sub config {
-
-    return cfs_read_file("networks.cfg");
+    my $config = cfs_read_file("networks.cfg.new");
+    $config = cfs_read_file("networks.cfg") if !keys %{$config->{ids}};
+    return $config;
 }
 
 sub write_config {
     my ($cfg) = @_;
 
-    cfs_write_file("networks.cfg", $cfg);
+    cfs_write_file("networks.cfg.new", $cfg);
 }
 
 sub lock_network_config {
     my ($code, $errmsg) = @_;
 
-    cfs_lock_file("networks.cfg", undef, $code);
+    cfs_lock_file("networks.cfg.new", undef, $code);
     my $err = $@;
     if ($err) {
         $errmsg ? die "$errmsg: $err" : die $err;
index e834434a3a1acd7d4febe178704cf6f45625d143..6c347116a1bb0474ece0276de7e964235f9f8e14 100644 (file)
@@ -12,6 +12,9 @@ use PVE::JSONSchema qw(get_standard_option);
 use base qw(PVE::SectionConfig);
 
 PVE::Cluster::cfs_register_file('networks.cfg',
+                                sub { __PACKAGE__->parse_config(@_); });
+
+PVE::Cluster::cfs_register_file('networks.cfg.new',
                                 sub { __PACKAGE__->parse_config(@_); },
                                 sub { __PACKAGE__->write_config(@_); });