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

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Apr 18 16:31:45 CEST 2016


---

changes since v1:
* only read resource configuration file once
* s/cfg/conf/ to match coding style of package better

 src/PVE/HA/Config.pm | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/src/PVE/HA/Config.pm b/src/PVE/HA/Config.pm
index f7440c0..a152e1c 100644
--- a/src/PVE/HA/Config.pm
+++ b/src/PVE/HA/Config.pm
@@ -192,4 +192,25 @@ sub service_is_ha_managed {
 
     return undef;
 }
+
+sub get_service_status {
+    my ($sid) = @_;
+
+    my $status = { managed => 0 };
+
+    my $conf = cfs_read_file($ha_resources_config);
+
+    if (&$servive_check_ha_state($conf, $sid)) {
+	my $sc = $conf->{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