From 80c0e9c4743c88a0cebb6964c5378f2c69024333 Mon Sep 17 00:00:00 2001 From: Alexandre Derumier Date: Mon, 6 May 2019 14:47:14 +0200 Subject: [PATCH] api: add apply and revert cluster network configuration Signed-off-by: Alexandre Derumier --- 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 @@ -154,6 +154,46 @@ __PACKAGE__->register_method ({ return undef; }}); +__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, -- 2.39.2