[pve-devel] [PATCH pve-network 1/4] remove .new files

Alexandre Derumier aderumier at odiso.com
Mon Apr 13 08:13:10 CEST 2020


---
 PVE/API2/Network/SDN.pm               | 15 ---------------
 PVE/API2/Network/SDN/Controllers.pm   | 22 ----------------------
 PVE/API2/Network/SDN/Vnets.pm         | 22 ----------------------
 PVE/API2/Network/SDN/Zones.pm         | 22 ----------------------
 PVE/Network/SDN/Controllers.pm        |  6 +++---
 PVE/Network/SDN/Controllers/Plugin.pm |  3 ---
 PVE/Network/SDN/VnetPlugin.pm         |  3 ---
 PVE/Network/SDN/Vnets.pm              |  8 +++-----
 PVE/Network/SDN/Zones.pm              |  7 +++----
 PVE/Network/SDN/Zones/Plugin.pm       |  3 ---
 10 files changed, 9 insertions(+), 102 deletions(-)

diff --git a/PVE/API2/Network/SDN.pm b/PVE/API2/Network/SDN.pm
index 65c8d52..4af2b6f 100644
--- a/PVE/API2/Network/SDN.pm
+++ b/PVE/API2/Network/SDN.pm
@@ -97,21 +97,6 @@ __PACKAGE__->register_method ({
         my $rpcenv = PVE::RPCEnvironment::get();
         my $authuser = $rpcenv->get_user();
 
-	if (-e "/etc/pve/sdn/controllers.cfg.new") {
-	    rename("/etc/pve/sdn/controllers.cfg.new", "/etc/pve/sdn/controllers.cfg")
-		|| die "applying sdn/controllers.cfg changes failed - $!\n";
-	}
-
-	if (-e "/etc/pve/sdn/zones.cfg.new") {
-	    rename("/etc/pve/sdn/zones.cfg.new", "/etc/pve/sdn/zones.cfg")
-		|| die "applying sdn/zones.cfg changes failed - $!\n";
-	}
-
-	if (-e "/etc/pve/sdn/vnets.cfg.new") {
-	    rename("/etc/pve/sdn/vnets.cfg.new", "/etc/pve/sdn/vnets.cfg")
-		|| die "applying sdn/vnets.cfg changes failed - $!\n";
-	}
-
         my $code = sub {
             $rpcenv->{type} = 'priv'; # to start tasks in background
 	    PVE::Cluster::check_cfs_quorum();
diff --git a/PVE/API2/Network/SDN/Controllers.pm b/PVE/API2/Network/SDN/Controllers.pm
index e16619c..50491eb 100644
--- a/PVE/API2/Network/SDN/Controllers.pm
+++ b/PVE/API2/Network/SDN/Controllers.pm
@@ -156,28 +156,6 @@ __PACKAGE__->register_method ({
 	return undef;
     }});
 
-__PACKAGE__->register_method ({
-    name => 'revert_configuration',
-    protected => 1,
-    path => '',
-    method => 'DELETE',
-    description => "Revert sdn controller changes.",
-    permissions => {
-	check => ['perm', '/sdn/controllers', ['SDN.Allocate']],
-    },
-    parameters => {
-	additionalProperties => 0,
-    },
-    returns => { type => 'null' },
-    code => sub {
-	my ($param) = @_;
-
-	die "no sdn controllers changes to revert" if !-e "/etc/pve/sdn/controllers.cfg.new";
-	unlink "/etc/pve/sdn/controllers.cfg.new";
-
-	return undef;
-    }});
-
 __PACKAGE__->register_method ({
     name => 'update',
     protected => 1,
diff --git a/PVE/API2/Network/SDN/Vnets.pm b/PVE/API2/Network/SDN/Vnets.pm
index cef631c..a9561f1 100644
--- a/PVE/API2/Network/SDN/Vnets.pm
+++ b/PVE/API2/Network/SDN/Vnets.pm
@@ -137,28 +137,6 @@ __PACKAGE__->register_method ({
 	return undef;
     }});
 
-__PACKAGE__->register_method ({
-    name => 'revert_configuration',
-    protected => 1,
-    path => '',
-    method => 'DELETE',
-    description => "Revert sdn vnet changes.",
-    permissions => {
-	check => ['perm', '/sdn/vnets', ['SDN.Allocate']],
-    },
-    parameters => {
-	additionalProperties => 0,
-    },
-    returns => { type => 'null' },
-    code => sub {
-	my ($param) = @_;
-
-	die "no sdn vnets changes to revert" if !-e "/etc/pve/sdn/vnets.cfg.new";
-	unlink "/etc/pve/sdn/vnets.cfg.new";
-
-	return undef;
-    }});
-
 __PACKAGE__->register_method ({
     name => 'update',
     protected => 1,
diff --git a/PVE/API2/Network/SDN/Zones.pm b/PVE/API2/Network/SDN/Zones.pm
index 293880a..9ea2189 100644
--- a/PVE/API2/Network/SDN/Zones.pm
+++ b/PVE/API2/Network/SDN/Zones.pm
@@ -164,28 +164,6 @@ __PACKAGE__->register_method ({
 	return undef;
     }});
 
-__PACKAGE__->register_method ({
-    name => 'revert_configuration',
-    protected => 1,
-    path => '',
-    method => 'DELETE',
-    description => "Revert sdn zone changes.",
-    permissions => {
-	check => ['perm', '/sdn/zones', ['SDN.Allocate']],
-    },
-    parameters => {
-	additionalProperties => 0,
-    },
-    returns => { type => 'null' },
-    code => sub {
-	my ($param) = @_;
-
-	die "no sdn zones changes to revert" if !-e "/etc/pve/sdn/zones.cfg.new";
-	unlink "/etc/pve/sdn/zones.cfg.new";
-
-	return undef;
-    }});
-
 __PACKAGE__->register_method ({
     name => 'update',
     protected => 1,
diff --git a/PVE/Network/SDN/Controllers.pm b/PVE/Network/SDN/Controllers.pm
index 16c664d..91a74d8 100644
--- a/PVE/Network/SDN/Controllers.pm
+++ b/PVE/Network/SDN/Controllers.pm
@@ -32,7 +32,7 @@ sub sdn_controllers_config {
 }
 
 sub config {
-    my $config = cfs_read_file("sdn/controllers.cfg.new");
+    my $config = cfs_read_file("sdn/controllers.cfg");
     $config = cfs_read_file("sdn/controllers.cfg") if !keys %{$config->{ids}};
     return $config;
 }
@@ -40,13 +40,13 @@ sub config {
 sub write_config {
     my ($cfg) = @_;
 
-    cfs_write_file("sdn/controllers.cfg.new", $cfg);
+    cfs_write_file("sdn/controllers.cfg", $cfg);
 }
 
 sub lock_sdn_controllers_config {
     my ($code, $errmsg) = @_;
 
-    cfs_lock_file("sdn/controllers.cfg.new", undef, $code);
+    cfs_lock_file("sdn/controllers.cfg", undef, $code);
     if (my $err = $@) {
         $errmsg ? die "$errmsg: $err" : die $err;
     }
diff --git a/PVE/Network/SDN/Controllers/Plugin.pm b/PVE/Network/SDN/Controllers/Plugin.pm
index 04eddca..06cd576 100644
--- a/PVE/Network/SDN/Controllers/Plugin.pm
+++ b/PVE/Network/SDN/Controllers/Plugin.pm
@@ -12,9 +12,6 @@ use PVE::JSONSchema qw(get_standard_option);
 use base qw(PVE::SectionConfig);
 
 PVE::Cluster::cfs_register_file('sdn/controllers.cfg',
-				 sub { __PACKAGE__->parse_config(@_); });
-
-PVE::Cluster::cfs_register_file('sdn/controllers.cfg.new',
 				 sub { __PACKAGE__->parse_config(@_); },
 				 sub { __PACKAGE__->write_config(@_); });
 
diff --git a/PVE/Network/SDN/VnetPlugin.pm b/PVE/Network/SDN/VnetPlugin.pm
index bd61209..b0280fc 100644
--- a/PVE/Network/SDN/VnetPlugin.pm
+++ b/PVE/Network/SDN/VnetPlugin.pm
@@ -8,9 +8,6 @@ use base qw(PVE::SectionConfig);
 use PVE::JSONSchema qw(get_standard_option);
 
 PVE::Cluster::cfs_register_file('sdn/vnets.cfg',
-                                 sub { __PACKAGE__->parse_config(@_); });
-
-PVE::Cluster::cfs_register_file('sdn/vnets.cfg.new',
                                  sub { __PACKAGE__->parse_config(@_); },
                                  sub { __PACKAGE__->write_config(@_); });
 
diff --git a/PVE/Network/SDN/Vnets.pm b/PVE/Network/SDN/Vnets.pm
index 725605b..ef698e8 100644
--- a/PVE/Network/SDN/Vnets.pm
+++ b/PVE/Network/SDN/Vnets.pm
@@ -22,21 +22,19 @@ sub sdn_vnets_config {
 }
 
 sub config {
-    my $config = cfs_read_file("sdn/vnets.cfg.new");
-    $config = cfs_read_file("sdn/vnets.cfg") if !keys %{$config->{ids}};
-    return $config;
+    my $config = cfs_read_file("sdn/vnets.cfg");
 }
 
 sub write_config {
     my ($cfg) = @_;
 
-    cfs_write_file("sdn/vnets.cfg.new", $cfg);
+    cfs_write_file("sdn/vnets.cfg", $cfg);
 }
 
 sub lock_sdn_vnets_config {
     my ($code, $errmsg) = @_;
 
-    cfs_lock_file("sdn/vnets.cfg.new", undef, $code);
+    cfs_lock_file("sdn/vnets.cfg", undef, $code);
     if (my $err = $@) {
         $errmsg ? die "$errmsg: $err" : die $err;
     }
diff --git a/PVE/Network/SDN/Zones.pm b/PVE/Network/SDN/Zones.pm
index e1a7081..9791494 100644
--- a/PVE/Network/SDN/Zones.pm
+++ b/PVE/Network/SDN/Zones.pm
@@ -38,8 +38,7 @@ sub sdn_zones_config {
 }
 
 sub config {
-    my $config = cfs_read_file("sdn/zones.cfg.new");
-    $config = cfs_read_file("sdn/zones.cfg") if !keys %{$config->{ids}};
+    my $config = cfs_read_file("sdn/zones.cfg");
     return $config;
 }
 
@@ -53,13 +52,13 @@ sub get_plugin_config {
 sub write_config {
     my ($cfg) = @_;
 
-    cfs_write_file("sdn/zones.cfg.new", $cfg);
+    cfs_write_file("sdn/zones.cfg", $cfg);
 }
 
 sub lock_sdn_zones_config {
     my ($code, $errmsg) = @_;
 
-    cfs_lock_file("sdn/zones.cfg.new", undef, $code);
+    cfs_lock_file("sdn/zones.cfg", undef, $code);
     if (my $err = $@) {
         $errmsg ? die "$errmsg: $err" : die $err;
     }
diff --git a/PVE/Network/SDN/Zones/Plugin.pm b/PVE/Network/SDN/Zones/Plugin.pm
index e4adcbd..aa53cce 100644
--- a/PVE/Network/SDN/Zones/Plugin.pm
+++ b/PVE/Network/SDN/Zones/Plugin.pm
@@ -13,9 +13,6 @@ use PVE::JSONSchema qw(get_standard_option);
 use base qw(PVE::SectionConfig);
 
 PVE::Cluster::cfs_register_file('sdn/zones.cfg',
-				 sub { __PACKAGE__->parse_config(@_); });
-
-PVE::Cluster::cfs_register_file('sdn/zones.cfg.new',
 				 sub { __PACKAGE__->parse_config(@_); },
 				 sub { __PACKAGE__->write_config(@_); });
 
-- 
2.20.1




More information about the pve-devel mailing list