[pve-devel] [PATCH ha-manager] Config: add get_service_status method

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Apr 18 14:52:01 CEST 2016


Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 src/PVE/HA/Config.pm | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/src/PVE/HA/Config.pm b/src/PVE/HA/Config.pm
index f7440c0..7c673e4 100644
--- a/src/PVE/HA/Config.pm
+++ b/src/PVE/HA/Config.pm
@@ -192,4 +192,24 @@ sub service_is_ha_managed {
 
     return undef;
 }
+
+sub get_service_status {
+    my ($sid) = @_;
+
+    my $status = { managed => 0 };
+
+    if (service_is_ha_managed($sid, undef, 1)) {
+	my $cfg = read_resources_config();
+	my $sc = $cfg->{ids}->{$sid};
+
+	my $manager_status = read_manager_status();
+
+	$status->{managed} = 1;
+	$status->{group} = $sc->{group};
+	$status->{state} = $manager_status->{service_status}->{$sid}->{state};
+    }
+
+    return $status;
+}
+
 1;
-- 
2.1.4




More information about the pve-devel mailing list