]> git.proxmox.com Git - pve-manager.git/commitdiff
api: bulk suspension: code clean-ups
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 13 Nov 2023 13:06:01 +0000 (14:06 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 13 Nov 2023 13:14:08 +0000 (14:14 +0100)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/API2/Nodes.pm

index e1e2c16b54fa9076fed4054cce8e627ecc512389..39b049d891d25cb68e715b4c5503ebb23cc35b5e 100644 (file)
@@ -2061,7 +2061,7 @@ __PACKAGE__->register_method ({
            if (scalar(@vms) > 0) {
                $rpcenv->check($authuser, "/vms/$_", [ 'VM.PowerMgmt' ]) for @vms;
            } else {
-               raise_perm_exc("/, VM.PowerMgmt  && VM.Config.Disk");
+               raise_perm_exc("/, VM.PowerMgmt && VM.Config.Disk");
            }
        }
 
@@ -2072,15 +2072,15 @@ __PACKAGE__->register_method ({
 
            $rpcenv->{type} = 'priv'; # to start tasks in background
 
-           my $stopList = $get_start_stop_list->($nodename, undef, $param->{vms});
+           my $toSuspendList = $get_start_stop_list->($nodename, undef, $param->{vms});
 
            my $cpuinfo = PVE::ProcFSTools::read_cpuinfo();
            my $datacenterconfig = cfs_read_file('datacenter.cfg');
            # if not set by user spawn max cpu count number of workers
            my $maxWorkers =  $datacenterconfig->{max_workers} || $cpuinfo->{cpus};
 
-           for my $order (sort {$b <=> $a} keys %$stopList) {
-               my $vmlist = $stopList->{$order};
+           for my $order (sort {$b <=> $a} keys %$toSuspendList) {
+               my $vmlist = $toSuspendList->{$order};
                my $workers = {};
 
                my $finish_worker = sub {
@@ -2106,10 +2106,10 @@ __PACKAGE__->register_method ({
                    next if !$task;
 
                    my $pid = $task->{pid};
-
                    $workers->{$pid} = { type => $d->{type}, upid => $upid, vmid => $vmid };
+
                    while (scalar(keys %$workers) >= $maxWorkers) {
-                       foreach my $p (keys %$workers) {
+                       for my $p (keys %$workers) {
                            if (!PVE::ProcFSTools::check_process_running($p)) {
                                $finish_worker->($p);
                            }