[pve-devel] [PATCH manager 02/15] broadcast ceph service data to cluster

Dominik Csapak d.csapak at proxmox.com
Mon May 27 14:13:53 CEST 2019


so that we have a list of all existing ceph services in the cluster

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 PVE/Service/pvestatd.pm | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/PVE/Service/pvestatd.pm b/PVE/Service/pvestatd.pm
index ce2adbbd..6cbd59fb 100755
--- a/PVE/Service/pvestatd.pm
+++ b/PVE/Service/pvestatd.pm
@@ -6,6 +6,8 @@ use warnings;
 use PVE::SafeSyslog;
 use PVE::Daemon;
 
+use JSON;
+
 use Time::HiRes qw (gettimeofday);
 use PVE::Tools qw(dir_glob_foreach file_read_firstline);
 use PVE::ProcFSTools;
@@ -22,6 +24,8 @@ use PVE::RPCEnvironment;
 use PVE::API2::Subscription;
 use PVE::AutoBalloon;
 use PVE::AccessControl;
+use PVE::Ceph::Services;
+use PVE::Ceph::Tools;
 
 use PVE::Status::Plugin;
 use PVE::Status::Graphite;
@@ -445,6 +449,21 @@ sub rotate_authkeys {
     PVE::AccessControl::rotate_authkey() if !PVE::AccessControl::check_authkey(1);
 }
 
+sub update_ceph_services {
+    my $services = PVE::Ceph::Services::get_local_services();
+    for my $type (keys %$services) {
+	my $data = encode_json($services->{$type});
+	PVE::Cluster::broadcast_node_kv("ceph-$type", $data);
+    }
+}
+
+sub update_ceph_version {
+    my ($version) = PVE::Ceph::Tools::get_local_version(1);
+    if ($version) {
+	PVE::Cluster::broadcast_node_kv("ceph-version", $version);
+    }
+}
+
 sub update_status {
 
     # update worker list. This is not really required and
@@ -503,6 +522,15 @@ sub update_status {
     $err = $@;
     syslog('err', "authkey rotation error: $err") if $err;
 
+    eval {
+	if (PVE::Ceph::Tools::check_ceph_inited(1)) {
+	    update_ceph_services();
+	    update_ceph_version();
+	}
+    };
+    $err = $@;
+    syslog('err', "error getting ceph services: $err") if $err;
+
 }
 
 my $next_update = 0;
-- 
2.11.0





More information about the pve-devel mailing list