[pve-devel] [PATCH v2 pve-manager 3/7] add storage check

Alexandre Derumier aderumier at odiso.com
Wed Oct 9 16:01:33 CEST 2019


Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/API2/Nodes.pm | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
index 9202932a..f86523b0 100644
--- a/PVE/API2/Nodes.pm
+++ b/PVE/API2/Nodes.pm
@@ -1964,6 +1964,7 @@ __PACKAGE__->register_method ({
 	my $maxWorkers = 1;
 	$maxWorkers = $param->{maxworkers} || $datacenterconfig->{max_workers} ||
 	    die "either 'maxworkers' parameter or max_workers in datacenter.cfg must be set!\n" if $target;
+	my $storecfg = PVE::Storage::config();
 
 	my $code = sub {
 	    $rpcenv->{type} = 'priv'; # to start tasks in background
@@ -1972,9 +1973,9 @@ __PACKAGE__->register_method ({
 	    my $workers = {};
 	    foreach my $vmid (sort keys %$vmlist) {
 		my $d = $vmlist->{$vmid};
-
 		if(!$target) {
-		
+
+		    my $vmconf = PVE::QemuConfig->load_config($vmid);
 		    my $members = PVE::Cluster::get_members();
 		    my $rrd = PVE::Cluster::rrd_dump();
 		    my $nodelist = PVE::Cluster::get_nodelist();
@@ -1996,7 +1997,8 @@ __PACKAGE__->register_method ({
 			next if $node_freecpu < $vm_cpu;
 			next if $node_freemem < $vm_mem;
 			next if $node_stats->{maxcpu} < $vm_stats->{maxcpu};
-			# fixme: check storage available
+			eval { PVE::QemuServer::check_storage_availability($storecfg, $vmconf, $node) };
+			next if $@;
 			# fixme: check vmbr available
 
 			my @vec_node = ($node_freecpu, $node_freemem); #? add network usage dimension ?
-- 
2.20.1




More information about the pve-devel mailing list