From 89ceb8026a9e3e01b58178f9f03a05179f24fd76 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Wed, 10 Feb 2016 11:58:25 +0100 Subject: [PATCH] use max_workers from datacenter.cfg for stopall/migrateall If set limit the maximal worker count to the new datacenter.cfg setting 'max_workers'. For stopall we prefer this over the cpu count if it's set. For migrateall we prefer the parameter but allow now to ommit the parameter and then we use the new setting if set. if both are not set we throw an error. Signed-off-by: Thomas Lamprecht --- PVE/API2/Nodes.pm | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm index c265c093..aa1fa0b8 100644 --- a/PVE/API2/Nodes.pm +++ b/PVE/API2/Nodes.pm @@ -1356,7 +1356,9 @@ __PACKAGE__->register_method ({ my $stopList = &$get_start_stop_list($nodename); my $cpuinfo = PVE::ProcFSTools::read_cpuinfo(); - my $maxWorkers = $cpuinfo->{cpus}; + 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}; foreach my $order (sort {$b <=> $a} keys %$stopList) { my $vmlist = $stopList->{$order}; @@ -1447,7 +1449,10 @@ __PACKAGE__->register_method ({ node => get_standard_option('pve-node'), target => get_standard_option('pve-node', { description => "Target node." }), maxworkers => { - description => "Max parralel migration job.", + description => "Maximal number of parallel migration job." . + " If not set use 'max_workers' from datacenter.cfg," . + " one of both must be set!", + optional => 1, type => 'integer', minimum => 1 }, @@ -1466,7 +1471,11 @@ __PACKAGE__->register_method ({ $nodename = PVE::INotify::nodename() if $nodename eq 'localhost'; my $target = $param->{target}; - my $maxWorkers = $param->{maxworkers}; + + my $datacenterconfig = cfs_read_file('datacenter.cfg'); + # prefer parameter over datacenter cfg settings + my $maxWorkers = $param->{maxworkers} || $datacenterconfig->{max_workers} || + die "either 'maxworkers' parameter or max_workers in datacenter.cfg must be set!\n"; my $code = sub {