[pve-devel] [PATCH 4/9] Add delsnapshot to LXC API2

Wolfgang Link w.link at proxmox.com
Fri Jul 17 09:26:46 CEST 2015


Signed-off-by: Wolfgang Link <w.link at proxmox.com>
---
 src/PVE/API2/LXC.pm | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/PVE/LXC.pm      |  6 ++++++
 src/pct             |  2 ++
 3 files changed, 56 insertions(+)

diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index e63b73b..1c4d788 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -1339,4 +1339,52 @@ __PACKAGE__->register_method({
 
 	return $rpcenv->fork_worker('pctsnapshot', $vmid, $authuser, $realcmd);
     }});
+
+__PACKAGE__->register_method({
+    name => 'delsnapshot',
+    path => '{vmid}/snapshot/{snapname}',
+    method => 'DELETE',
+    protected => 1,
+    proxyto => 'node',
+    description => "Delete a LXC 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'),
+	    force => {
+		optional => 1,
+		type => 'boolean',
+		description => "For removal from config file, even if removing disk snapshots fails.",
+	    },
+	},
+    },
+    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, "delete snapshot VM $vmid: $snapname");
+	    PVE::LXC::snapshot_delete($vmid, $snapname, $param->{force});
+	};
+
+	return $rpcenv->fork_worker('lxcdelsnapshot', $vmid, $authuser, $realcmd);
+    }});
 1;
diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index dc351c6..d52b743 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -1555,4 +1555,10 @@ sub snapshot_create {
     }
 }
 
+sub snapshot_delete {
+    my ($vmid, $snapname, $force) = @_;
+
+    print "Not implemented\n";
+}
+
 1;
diff --git a/src/pct b/src/pct
index 06affa0..e90f565 100755
--- a/src/pct
+++ b/src/pct
@@ -125,6 +125,8 @@ my $cmddef = {
 
     snapshot => [ "PVE::API2::LXC", 'snapshot', ['vmid', 'snapname'],
 		  { node => $nodename } , $upid_exit ],
+
+    delsnapshot => [ "PVE::API2::LXC", 'delsnapshot', ['vmid', 'snapname'], { node => $nodename } , $upid_exit ],
 };
 			      
 my $cmd = shift;
-- 
2.1.4





More information about the pve-devel mailing list