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

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Apr 18 16:51:53 CEST 2016


---

changes since v2:
* stay consistent with wrappers and always use cfs_read_file (ugh, sorry that
  I missed that for v2)
* remove intermediate "$sc" var, as it does not really provides a readability
  benefit

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

diff --git a/src/PVE/HA/Config.pm b/src/PVE/HA/Config.pm
index f7440c0..b4c03a2 100644
--- a/src/PVE/HA/Config.pm
+++ b/src/PVE/HA/Config.pm
@@ -192,4 +192,23 @@ 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 $manager_status = cfs_read_file($manager_status_filename);
+
+	$status->{managed} = 1;
+	$status->{group} = $conf->{ids}->{$sid}->{group};
+	$status->{state} = $manager_status->{service_status}->{$sid}->{state};
+    }
+
+    return $status;
+}
+
 1;
-- 
2.1.4





More information about the pve-devel mailing list