]> git.proxmox.com Git - pve-manager.git/commitdiff
run openvz destroy_vm as background task
authorDietmar Maurer <dietmar@proxmox.com>
Mon, 10 Oct 2011 07:15:11 +0000 (09:15 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 10 Oct 2011 07:15:11 +0000 (09:15 +0200)
PVE/API2/OpenVZ.pm

index 0d2b07a94b2813754ec8349555f2de5a5ddcbd68..a06783e30d505a378b96b4fe74fb39c80ee3c17a 100644 (file)
@@ -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;