From: Alexandre Derumier Date: Mon, 6 May 2019 12:47:14 +0000 (+0200) Subject: api: add apply and revert cluster network configuration X-Git-Url: https://git.proxmox.com/?p=pve-network.git;a=commitdiff_plain;h=80c0e9c4743c88a0cebb6964c5378f2c69024333 api: add apply and revert cluster network configuration Signed-off-by: Alexandre Derumier --- 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,