[pve-devel] [PATCH manager 1/5] ceph: factor out get/broadcast ceph versions to ceph::services
Dominik Csapak
d.csapak at proxmox.com
Mon Mar 16 13:55:59 CET 2020
which also removes some dead code
(the my $local_last_version variable was never used)
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
PVE/API2/Cluster/Ceph.pm | 6 ++----
PVE/Ceph/Services.pm | 30 ++++++++++++++++++++++++++++++
PVE/Service/pvestatd.pm | 19 +------------------
3 files changed, 33 insertions(+), 22 deletions(-)
diff --git a/PVE/API2/Cluster/Ceph.pm b/PVE/API2/Cluster/Ceph.pm
index 9e3cce50..71d5cde6 100644
--- a/PVE/API2/Cluster/Ceph.pm
+++ b/PVE/API2/Cluster/Ceph.pm
@@ -74,10 +74,8 @@ __PACKAGE__->register_method ({
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
- };
+ if (defined(my $vers = PVE::Ceph::Services::get_ceph_versions())) {
+ $res->{node} = $vers;
}
for my $type ( qw(mon mgr mds) ) {
diff --git a/PVE/Ceph/Services.pm b/PVE/Ceph/Services.pm
index c17008cf..ef46b9ea 100644
--- a/PVE/Ceph/Services.pm
+++ b/PVE/Ceph/Services.pm
@@ -47,6 +47,36 @@ sub broadcast_ceph_services {
}
}
+sub broadcast_ceph_versions {
+ my ($version, $buildcommit, $vers_parts) = PVE::Ceph::Tools::get_local_version(1);
+
+ if ($version) {
+ # FIXME: remove with 7.0 - for backward compat only
+ 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));
+ }
+}
+
+sub get_ceph_versions {
+ my $res;
+
+ if (defined(my $vers = PVE::Cluster::get_node_kv("ceph-versions"))) {
+ $res = {
+ map { eval { $_ => decode_json($vers->{$_}) } } keys %$vers
+ };
+ }
+
+ return $res;
+}
+
sub get_cluster_service {
my ($type) = @_;
diff --git a/PVE/Service/pvestatd.pm b/PVE/Service/pvestatd.pm
index 88fb31ac..7899427d 100755
--- a/PVE/Service/pvestatd.pm
+++ b/PVE/Service/pvestatd.pm
@@ -465,24 +465,7 @@ sub update_ceph_metadata {
PVE::Ceph::Services::broadcast_ceph_services();
- 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) {
- # FIXME: remove with 7.0 - for backward compat only
- 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));
- }
+ PVE::Ceph::Services::broadcast_ceph_versions();
}
sub update_sdn_status {
--
2.20.1
More information about the pve-devel
mailing list