esxi: deactivate storage if config gets updated

to ensure that the next access actually uses the updated config for
accessing the remote ESXi, for both manifest API and FUSE mount.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht
2024-03-12 18:34:33 +01:00
parent 68f3ec3f8b
commit 0a2f75ffd6

View File

@ -314,13 +314,23 @@ sub on_add_hook {
sub on_update_hook { sub on_update_hook {
my ($class, $storeid, $scfg, %sensitive) = @_; my ($class, $storeid, $scfg, %sensitive) = @_;
return if !exists($sensitive{password}); # FIXME: allow to actually determine this, e.g., through new $changed hash passed to the hook
my $connection_detail_changed = 1;
if (exists($sensitive{password})) {
$connection_detail_changed = 1;
if (defined($sensitive{password})) { if (defined($sensitive{password})) {
esxi_set_credentials($sensitive{password}, $storeid); esxi_set_credentials($sensitive{password}, $storeid);
} else { } else {
esxi_delete_credentials($storeid); esxi_delete_credentials($storeid);
} }
}
if ($connection_detail_changed) {
# best-effort deactivate storage so that it can get re-mounted with updated params
eval { $class->deactivate_storage($storeid, $scfg) };
warn $@ if $@;
}
return; return;
} }