From: Dietmar Maurer Date: Mon, 10 Oct 2011 07:15:11 +0000 (+0200) Subject: run openvz destroy_vm as background task X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=a42f6acbcb409014f42a7af35145b152d003748e;p=pve-manager.git run openvz destroy_vm as background task --- diff --git a/PVE/API2/OpenVZ.pm b/PVE/API2/OpenVZ.pm index 0d2b07a9..a06783e3 100644 --- a/PVE/API2/OpenVZ.pm +++ b/PVE/API2/OpenVZ.pm @@ -454,7 +454,9 @@ __PACKAGE__->register_method({ vmid => get_standard_option('pve-vmid'), }, }, - returns => { type => 'null' }, + returns => { + type => 'string', + }, code => sub { my ($param) = @_; @@ -467,11 +469,13 @@ __PACKAGE__->register_method({ # test if VM exists my $conf = PVE::OpenVZ::load_config($param->{vmid}); - my $cmd = ['vzctl', 'destroy', $vmid ]; + my $realcmd = sub { + my $cmd = ['vzctl', 'destroy', $vmid ]; - PVE::Tools::run_command($cmd); + PVE::Tools::run_command($cmd); + }; - return undef; + return $rpcenv->fork_worker('vzdestroy', $vmid, $user, $realcmd); }}); my $sslcert;