[pve-devel] [PATCH pve-ha-manager 1/2] vm_is_ha_managed: allow check on service state

Thomas Lamprecht t.lamprecht at proxmox.com
Fri Sep 18 11:21:02 CEST 2015


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

diff --git a/src/PVE/HA/Config.pm b/src/PVE/HA/Config.pm
index a9913da..1bb37a3 100644
--- a/src/PVE/HA/Config.pm
+++ b/src/PVE/HA/Config.pm
@@ -158,7 +158,7 @@ sub read_crm_commands {
 }
 
 sub vm_is_ha_managed {
-    my ($vmid) = @_;
+    my ($vmid, $has_state) = @_;
 
     my $conf = cfs_read_file($ha_resources_config);
 
@@ -166,7 +166,10 @@ sub vm_is_ha_managed {
     foreach my $type (@$types) {
 	my $sid = "$type:$vmid";
 
-	return 1 if defined($conf->{ids}->{$sid});
+	if (my $vm = $conf->{ids}->{$sid}) {
+	    $vm->{state} = 'enabled' if !defined($vm->{state});
+	    return !defined($has_state) || $vm->{state} eq $has_state;
+	}
 }
 
     return undef;
-- 
2.1.4



More information about the pve-devel mailing list