[pve-devel] [PATCH] add the capability to unlock a Container if it is locked

Wolfgang Link w.link at proxmox.com
Fri Sep 4 11:57:45 CEST 2015


---
 src/PVE/CLI/pct.pm | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/src/PVE/CLI/pct.pm b/src/PVE/CLI/pct.pm
index a9f7716..c24600e 100755
--- a/src/PVE/CLI/pct.pm
+++ b/src/PVE/CLI/pct.pm
@@ -28,6 +28,32 @@ my $upid_exit = sub {
 };
 
 __PACKAGE__->register_method ({
+    name => 'unlock',
+    path => 'unlock',
+    method => 'PUT',
+    description => "Unlock the VM.",
+    parameters => {
+	additionalProperties => 0,
+	properties => {
+	    vmid => get_standard_option('pve-vmid', { completion => \&PVE::LXC::complete_ctid }),
+	},
+    },
+    returns => { type => 'null'},
+    code => sub {
+	my ($param) = @_;
+
+	my $vmid = $param->{vmid};
+
+	PVE::LXC::lock_container($vmid, 5, sub {
+	    my $conf = PVE::LXC::load_config($vmid);
+	    delete $conf->{lock};
+	    PVE::LXC::write_config($vmid, $conf);
+	});
+
+	return undef;
+    }});
+
+__PACKAGE__->register_method ({
     name => 'console',
     path => 'console',
     method => 'GET',
@@ -135,6 +161,7 @@ our $cmddef = {
     
     console => [ __PACKAGE__, 'console', ['vmid']],
     enter => [ __PACKAGE__, 'enter', ['vmid']],
+    unlock => [ __PACKAGE__, 'unlock', ['vmid']],
     exec => [ __PACKAGE__, 'exec', ['vmid', 'extra-args']],
     
     destroy => [ 'PVE::API2::LXC', 'destroy_vm', ['vmid'], 
-- 
2.1.4




More information about the pve-devel mailing list