]> git.proxmox.com Git - qemu-server.git/commitdiff
check_local_storage_availability: only count each unavailable storage once
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 28 Jun 2019 15:23:44 +0000 (17:23 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 28 Jun 2019 15:39:16 +0000 (17:39 +0200)
and some general cleanup

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/API2/Qemu.pm
PVE/QemuServer.pm

index 1c4e07ba9a3532a1e8ac2ecae8d5cd033579950d..e2a63be1b05501640ebd5acc97e0228fac894cd2 100644 (file)
@@ -3211,12 +3211,11 @@ __PACKAGE__->register_method({
        if (!$res->{running}) {
            $res->{allowed_nodes} = [];
            my $checked_nodes = PVE::QemuServer::check_local_storage_availability($vmconf, $storecfg);
+           delete $checked_nodes->{$localnode};
 
-           delete $checked_nodes->{$localnode} if $checked_nodes->{$localnode};
            foreach my $node (keys %$checked_nodes) {
-               if (!defined $checked_nodes->{$node}->{not_available_storages}){
+               if (!defined $checked_nodes->{$node}->{unavailable_storages}) {
                    push @{$res->{allowed_nodes}}, $node;
-                   delete $checked_nodes->{$node};
                }
 
            }
index 35e263313160e2311076e89044f9d179765d348e..b4b15801dc51ba30d6201c0f1d8ec1dcb4e2914d 100644 (file)
@@ -2942,18 +2942,24 @@ sub check_local_storage_availability {
 
            if ($scfg->{disable}) {
                foreach my $node (keys %$nodehash) {
-                   push @{$nodehash->{$node}->{not_available_storages}}, $storeid;
+                   $nodehash->{$node}->{unavailable_storages}->{$storeid} = 1;
                }
            } elsif (my $avail = $scfg->{nodes}) {
                foreach my $node (keys %$nodehash) {
                    if (!$avail->{$node}) {
-                       push @{$nodehash->{$node}->{not_available_storages}}, $storeid;
+                       $nodehash->{$node}->{unavailable_storages}->{$storeid} = 1;
                    }
                }
            }
        }
     });
 
+    foreach my $node (values %$nodehash) {
+       if (my $unavail = $node->{unavailable_storages}) {
+           $node->{unavailable_storages} = [ sort keys %$unavail ];
+       }
+    }
+
     return $nodehash
 }