[pve-devel] [PATCH pve-network 3/3] api: add apply and revert cluster network configuration
Alexandre Derumier
aderumier at odiso.com
Mon May 6 14:47:14 CEST 2019
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
PVE/API2/Network/Network.pm | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/PVE/API2/Network/Network.pm b/PVE/API2/Network/Network.pm
index 524c6c3..9c73d19 100644
--- a/PVE/API2/Network/Network.pm
+++ b/PVE/API2/Network/Network.pm
@@ -155,6 +155,46 @@ __PACKAGE__->register_method ({
}});
__PACKAGE__->register_method ({
+ name => 'apply_configuration',
+ protected => 1,
+ path => '',
+ method => 'PUT',
+ description => "Apply network changes.",
+# permissions => {
+# check => ['perm', '/cluster/network', ['Network.Allocate']],
+# },
+ returns => { type => 'null' },
+ code => sub {
+ my ($param) = @_;
+
+ die "no network changes to apply" if !-e "/etc/pve/networks.cfg.new";
+ rename("/etc/pve/networks.cfg.new", "/etc/pve/networks.cfg")
+ || die "applying networks.cfg changes failed - $!\n";
+
+
+ return undef;
+ }});
+
+__PACKAGE__->register_method ({
+ name => 'revert_configuration',
+ protected => 1,
+ path => '',
+ method => 'DELETE',
+ description => "Revert network changes.",
+# permissions => {
+# check => ['perm', '/cluster/network', ['Network.Allocate']],
+# },
+ returns => { type => 'null' },
+ code => sub {
+ my ($param) = @_;
+
+ die "no network changes to revert" if !-e "/etc/pve/networks.cfg.new";
+ unlink "/etc/pve/networks.cfg.new";
+
+ return undef;
+ }});
+
+__PACKAGE__->register_method ({
name => 'update',
protected => 1,
path => '{network}',
--
2.11.0
More information about the pve-devel
mailing list