]> git.proxmox.com Git - pve-network.git/commitdiff
api: add apply and revert cluster network configuration
authorAlexandre Derumier <aderumier@odiso.com>
Mon, 6 May 2019 12:47:14 +0000 (14:47 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 8 May 2019 06:03:27 +0000 (08:03 +0200)
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
PVE/API2/Network/Network.pm

index 524c6c304cc861ded87cb0b278524c6a1f3b674f..9c73d19af013abb82b73a01975c71e0f66a0e565 100644 (file)
@@ -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,