[pve-devel] [PATCH 6/9] Add snapshot rollback to API2
Wolfgang Link
w.link at proxmox.com
Fri Jul 17 09:26:48 CEST 2015
Signed-off-by: Wolfgang Link <w.link at proxmox.com>
---
src/PVE/API2/LXC.pm | 43 +++++++++++++++++++++++++++++++++++++++++++
src/PVE/LXC.pm | 5 +++++
src/pct | 2 ++
3 files changed, 50 insertions(+)
diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index 1c4d788..daf68ca 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -1387,4 +1387,47 @@ __PACKAGE__->register_method({
return $rpcenv->fork_worker('lxcdelsnapshot', $vmid, $authuser, $realcmd);
}});
+__PACKAGE__->register_method({
+ name => 'rollback',
+ path => '{vmid}/snapshot/{snapname}/rollback',
+ method => 'POST',
+ protected => 1,
+ proxyto => 'node',
+ description => "Rollback LXC state to specified snapshot.",
+ permissions => {
+ check => ['perm', '/vms/{vmid}', [ 'VM.Snapshot' ]],
+ },
+ parameters => {
+ additionalProperties => 0,
+ properties => {
+ node => get_standard_option('pve-node'),
+ vmid => get_standard_option('pve-vmid'),
+ snapname => get_standard_option('pve-lxc-snapshot-name'),
+ },
+ },
+ returns => {
+ type => 'string',
+ description => "the task ID.",
+ },
+ code => sub {
+ my ($param) = @_;
+
+ my $rpcenv = PVE::RPCEnvironment::get();
+
+ my $authuser = $rpcenv->get_user();
+
+ my $node = extract_param($param, 'node');
+
+ my $vmid = extract_param($param, 'vmid');
+
+ my $snapname = extract_param($param, 'snapname');
+
+ my $realcmd = sub {
+ PVE::Cluster::log_msg('info', $authuser, "rollback snapshot LXC $vmid: $snapname");
+ PVE::LXC::snapshot_rollback($vmid, $snapname);
+ };
+
+ return $rpcenv->fork_worker('lxcrollback', $vmid, $authuser, $realcmd);
+ }});
+
1;
diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index ff4eef9..668d0d2 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -1613,4 +1613,9 @@ sub snapshot_delete {
}
}
+sub snapshot_rollback {
+ my ($vmid, $snapname) = @_;
+
+ die "Not implemented\n";
+}
1;
diff --git a/src/pct b/src/pct
index e90f565..3a186f4 100755
--- a/src/pct
+++ b/src/pct
@@ -127,6 +127,8 @@ my $cmddef = {
{ node => $nodename } , $upid_exit ],
delsnapshot => [ "PVE::API2::LXC", 'delsnapshot', ['vmid', 'snapname'], { node => $nodename } , $upid_exit ],
+
+ rollback => [ "PVE::API2::LXC", 'rollback', ['vmid', 'snapname'], { node => $nodename } , $upid_exit ],
};
my $cmd = shift;
--
2.1.4
More information about the pve-devel
mailing list