mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-13 02:25:32 +00:00
api/bulk migrate: rework pre-condition check outputs
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
736cffb1f9
commit
0b54f653ca
@ -1927,26 +1927,25 @@ my $create_migrate_worker = sub {
|
|||||||
$upid = PVE::API2::LXC->migrate_vm({node => $nodename, vmid => $vmid, target => $target,
|
$upid = PVE::API2::LXC->migrate_vm({node => $nodename, vmid => $vmid, target => $target,
|
||||||
restart => $online });
|
restart => $online });
|
||||||
} elsif ($type eq 'qemu') {
|
} elsif ($type eq 'qemu') {
|
||||||
|
print STDERR "Check VM $vmid: ";
|
||||||
|
*STDERR->flush();
|
||||||
my $online = PVE::QemuServer::check_running($vmid, 1) ? 1 : 0;
|
my $online = PVE::QemuServer::check_running($vmid, 1) ? 1 : 0;
|
||||||
my $preconditions = PVE::API2::Qemu->migrate_vm_precondition({node => $nodename, vmid => $vmid, target => $target});
|
my $preconditions = PVE::API2::Qemu->migrate_vm_precondition({node => $nodename, vmid => $vmid, target => $target});
|
||||||
my $invalidConditions = 0;
|
my $invalidConditions = '';
|
||||||
print STDERR "Check VM $vmid:\n";
|
if ($online && !$with_local_disks && scalar @{$preconditions->{local_disks}}) {
|
||||||
if ($online && !$with_local_disks && @{$preconditions->{local_disks}}) {
|
$invalidConditions .= "\n Has local disks: " .
|
||||||
$invalidConditions = 1;
|
join(', ', map { $_->{volid} } @{$preconditions->{local_disks}});
|
||||||
my $local_disks = [];
|
|
||||||
foreach my $disk (@{$preconditions->{local_disks}}) {
|
|
||||||
push @$local_disks, $disk->{volid};
|
|
||||||
}
|
|
||||||
print STDERR "Has local disks -> ". join(",",@$local_disks) . "\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (@{$preconditions->{local_resources}}) {
|
if (@{$preconditions->{local_resources}}) {
|
||||||
$invalidConditions = 1;
|
$invalidConditions .= "\n Has local resources: " . join(', ', @{$preconditions->{local_resources}});
|
||||||
print STDERR "Has local resources -> " . join(',',@{$preconditions->{local_resources}}) . "\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
die "Skip VM $vmid: Precondition check failed\n" if $invalidConditions;
|
if ($invalidConditions && $invalidConditions ne '') {
|
||||||
print STDERR "Precondition check passed\n";
|
print STDERR "skip VM $vmid - precondition check failed:";
|
||||||
|
die "$invalidConditions\n";
|
||||||
|
}
|
||||||
|
print STDERR "precondition check passed\n";
|
||||||
print STDERR "Migrating VM $vmid\n";
|
print STDERR "Migrating VM $vmid\n";
|
||||||
$upid = PVE::API2::Qemu->migrate_vm({node => $nodename, vmid => $vmid, target => $target,
|
$upid = PVE::API2::Qemu->migrate_vm({node => $nodename, vmid => $vmid, target => $target,
|
||||||
online => $online, 'with-local-disks' => $with_local_disks});
|
online => $online, 'with-local-disks' => $with_local_disks});
|
||||||
|
Loading…
Reference in New Issue
Block a user