api: ceph/metadata: add structured node versions

include the version as string and as parts, as we do the split
already. Also include the build commit, so if we re-release a ceph
version, we can differ here too.

Use node as key, to make the new entry a bit more general, could be
easily expanded with other infos, if required.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2019-11-15 17:24:45 +01:00
parent 3248590d53
commit 1aaca6fde7
2 changed files with 24 additions and 1 deletions

View File

@ -3,6 +3,8 @@ package PVE::API2::Cluster::Ceph;
use strict; use strict;
use warnings; use warnings;
use JSON;
use PVE::Ceph::Services; use PVE::Ceph::Services;
use PVE::Ceph::Tools; use PVE::Ceph::Tools;
use PVE::Cluster; use PVE::Cluster;
@ -68,9 +70,16 @@ __PACKAGE__->register_method ({
my $rados = PVE::RADOS->new(); my $rados = PVE::RADOS->new();
my $res = { my $res = {
# FIXME: remove with 7.0 depreacated by structured 'versions'
version => PVE::Cluster::get_node_kv("ceph-version"), version => PVE::Cluster::get_node_kv("ceph-version"),
}; };
if (defined(my $vers = PVE::Cluster::get_node_kv("ceph-versions"))) {
$res->{node} = {
map { eval { $_ => decode_json($vers->{$_}) } } keys %$vers
};
}
for my $type ( qw(mon mgr mds) ) { for my $type ( qw(mon mgr mds) ) {
my $typedata = PVE::Ceph::Services::get_cluster_service($type); my $typedata = PVE::Ceph::Services::get_cluster_service($type);
my $data = {}; my $data = {};

View File

@ -416,9 +416,23 @@ sub update_ceph_metadata {
PVE::Ceph::Services::broadcast_ceph_services(); PVE::Ceph::Services::broadcast_ceph_services();
my ($version) = PVE::Ceph::Tools::get_local_version(1); my ($version, $buildcommit, $vers_parts) = PVE::Ceph::Tools::get_local_version(1);
my $local_last_version = PVE::Cluster::get_node_kv('ceph-versions');
if ($version) { if ($version) {
# FIXME: remove with 7.0 - for backward compat only
PVE::Cluster::broadcast_node_kv("ceph-version", $version); PVE::Cluster::broadcast_node_kv("ceph-version", $version);
my $node_versions = {
version => {
str => $version,
parts => $vers_parts,
},
buildcommit => $buildcommit,
};
PVE::Cluster::broadcast_node_kv("ceph-versions", encode_json($node_versions));
} }
} }