api: cluster/ceph: allow version metadata call on non-ceph nodes

the information comes only from the key value store in the pmxcfs, so
we do not actually require ceph to be installed.

So only check if ceph is locally initialized and create the rados
connection after the early return when only versions scope is set.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2020-11-22 16:12:58 +01:00
parent 2a5d20c843
commit cf485f2a36

View File

@ -72,9 +72,6 @@ __PACKAGE__->register_method ({
code => sub {
my ($param) = @_;
PVE::Ceph::Tools::check_ceph_inited();
my $rados = PVE::RADOS->new();
my $scope = $param->{scope} // 'all';
my $res = {
@ -82,12 +79,16 @@ __PACKAGE__->register_method ({
version => PVE::Cluster::get_node_kv("ceph-version"),
};
if (defined(my $vers = PVE::Ceph::Services::get_ceph_versions())) {
$res->{node} = $vers;
if (defined(my $versions = PVE::Ceph::Services::get_ceph_versions())) {
$res->{node} = $versions;
}
return $res if ($scope eq 'versions');
# only check now, we want to allow calls with scope 'versions' on non-ceph nodes too!
PVE::Ceph::Tools::check_ceph_inited();
my $rados = PVE::RADOS->new();
for my $type ( qw(mon mgr mds) ) {
my $typedata = PVE::Ceph::Services::get_cluster_service($type);
my $data = {};