api/migration: fix autocomplete for targetstorage

Show storages configured for the target node and not for the current one
because they can be different.

Duplicated the `complete_storage` sub and extended it to extract the
targetnode from the parameters to pass it into the storage_check_enabled
function.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
This commit is contained in:
Aaron Lauterer 2019-11-18 15:23:18 +01:00 committed by Thomas Lamprecht
parent 340d8b7510
commit 255e9c546c
2 changed files with 19 additions and 1 deletions

View File

@ -3302,7 +3302,7 @@ __PACKAGE__->register_method({
targetstorage => get_standard_option('pve-storage-id', {
description => "Default target storage.",
optional => 1,
completion => \&PVE::QemuServer::complete_storage,
completion => \&PVE::QemuServer::complete_migration_storage,
}),
bwlimit => {
description => "Override I/O bandwidth limit (in KiB/s).",

View File

@ -7482,4 +7482,22 @@ sub complete_storage {
return $res;
}
sub complete_migration_storage {
my ($cmd, $param, $current_value, $all_args) = @_;
my $targetnode = @$all_args[1];
my $cfg = PVE::Storage::config();
my $ids = $cfg->{ids};
my $res = [];
foreach my $sid (keys %$ids) {
next if !PVE::Storage::storage_check_enabled($cfg, $sid, $targetnode, 1);
next if !$ids->{$sid}->{content}->{images};
push @$res, $sid;
}
return $res;
}
1;