From 8b62ac6a0ce0d4757ce25082123d18434f5b3a58 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Tue, 1 Dec 2020 19:15:49 +0100 Subject: [PATCH] pbs: add scan datastore helper for use in both, the scan API and the on_add/on_update hooks Signed-off-by: Thomas Lamprecht --- PVE/Storage/PBSPlugin.pm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/PVE/Storage/PBSPlugin.pm b/PVE/Storage/PBSPlugin.pm index f648291..f04f9f7 100644 --- a/PVE/Storage/PBSPlugin.pm +++ b/PVE/Storage/PBSPlugin.pm @@ -645,6 +645,24 @@ my sub pbs_api_connect { return $conn; } +# can also be used for not (yet) added storages, pass $scfg with +# { +# server +# user +# port (optional default to 8007) +# fingerprint (optional for trusted certs) +# } +sub scan_datastores { + my ($scfg, $password) = @_; + + my $conn = pbs_api_connect($scfg, $password); + + my $response = eval { $conn->get('/api2/json/admin/datastore', {}) }; + die "error fetching datastores - $@" if $@; + + return $response; +} + sub activate_storage { my ($class, $storeid, $scfg, $cache) = @_;