pbs: activate storage: fully validate if storage config works
improves UX of on_update and on_add hooks *a lot*. This is a bit more expensive than the TCP ping, or even just an unauthenticated ping, but not as bad as a full datastore status - as this only reads the datastore config file (which is normally in page cache anyway). Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
@ -666,13 +666,20 @@ sub scan_datastores {
|
|||||||
sub activate_storage {
|
sub activate_storage {
|
||||||
my ($class, $storeid, $scfg, $cache) = @_;
|
my ($class, $storeid, $scfg, $cache) = @_;
|
||||||
|
|
||||||
# a 'status' client command is to expensive here
|
my $password = pbs_get_password($scfg, $storeid);
|
||||||
# TODO: use a dummy ping API call to ensure the PBS API daemon is available for real
|
|
||||||
my $server = $scfg->{server};
|
|
||||||
my $port = $scfg->{port} // 8007;
|
|
||||||
PVE::Network::tcp_ping($server, $port, 2);
|
|
||||||
|
|
||||||
return 1;
|
my $datastores = eval { scan_datastores($scfg, $password) };
|
||||||
|
die "$storeid: $@" if $@;
|
||||||
|
|
||||||
|
my $datastore = $scfg->{datastore};
|
||||||
|
|
||||||
|
for my $ds (@$datastores) {
|
||||||
|
if ($ds->{store} eq $datastore) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
die "$storeid: Cannot find datastore '$datastore', check permissions and existance!\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub deactivate_storage {
|
sub deactivate_storage {
|
||||||
|
|||||||
Reference in New Issue
Block a user