On Wed Mar 20, 2024 at 1:51 PM CET, Dominik Csapak wrote:
> so that we can show a proper warning in the migrate dialog and check it
> in the bulk migrate precondition check
>
> the unavailable_storages and allowed_nodes should be the same as before
>
> Signed-off-by: Dominik Csapak <d.csa...@proxmox.com>
> ---
> not super happy with this partial approach, we probably should just
> always return the 'allowed_nodes' and 'not_allowed_nodes' and change
> the gui to handle the running vs not running state?
>
>  PVE/API2/Qemu.pm | 27 +++++++++++++++------------
>  1 file changed, 15 insertions(+), 12 deletions(-)
>
> diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
> index 8581a529..b0f155f7 100644
> --- a/PVE/API2/Qemu.pm
> +++ b/PVE/API2/Qemu.pm
> @@ -4439,7 +4439,7 @@ __PACKAGE__->register_method({
>           not_allowed_nodes => {
>               type => 'object',
>               optional => 1,
> -             description => "List not allowed nodes with additional 
> informations, only passed if VM is offline"
> +             description => "List not allowed nodes with additional 
> informations",

"information" has no plural, this should just be "additional
information".

>           },
>           local_disks => {
>               type => 'array',
> @@ -4496,25 +4496,28 @@ __PACKAGE__->register_method({
>
>       # if vm is not running, return target nodes where local storage/mapped 
> devices are available
>       # for offline migration
> +     my $checked_nodes = {};
> +     my $allowed_nodes = [];
>       if (!$res->{running}) {
> -         $res->{allowed_nodes} = [];
> -         my $checked_nodes = 
> PVE::QemuServer::check_local_storage_availability($vmconf, $storecfg);
> +         $checked_nodes = 
> PVE::QemuServer::check_local_storage_availability($vmconf, $storecfg);
>           delete $checked_nodes->{$localnode};
> +     }
>
> -         foreach my $node (keys %$checked_nodes) {
> -             my $missing_mappings = $missing_mappings_by_node->{$node};
> -             if (scalar($missing_mappings->@*)) {
> -                 $checked_nodes->{$node}->{'unavailable-resources'} = 
> $missing_mappings;
> -                 next;
> -             }
> +     foreach my $node ((keys $checked_nodes->%*, keys 
> $missing_mappings_by_node->%*)) {
> +         my $missing_mappings = $missing_mappings_by_node->{$node};
> +         if (scalar($missing_mappings->@*)) {
> +             $checked_nodes->{$node}->{'unavailable-resources'} = 
> $missing_mappings;
> +             next;
> +         }
>
> +         if (!$res->{running}) {
>               if (!defined($checked_nodes->{$node}->{unavailable_storages})) {
> -                 push @{$res->{allowed_nodes}}, $node;
> +                 push $allowed_nodes->@*, $node;
>               }
> -
>           }
> -         $res->{not_allowed_nodes} = $checked_nodes;
>       }
> +     $res->{not_allowed_nodes} = $checked_nodes if 
> scalar(keys($checked_nodes->%*)) || !$res->{running};
> +     $res->{allowed_nodes} = $allowed_nodes if scalar($allowed_nodes->@*) || 
> !$res->{running};
>
>       my $local_disks = &$check_vm_disks_local($storecfg, $vmconf, $vmid);
>       $res->{local_disks} = [ values %$local_disks ];;



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to