]> git.proxmox.com Git - pve-ha-manager.git/commitdiff
vm_is_ha_managed: allow check on service state
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 18 Sep 2015 09:21:02 +0000 (11:21 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Sun, 20 Sep 2015 07:52:31 +0000 (09:52 +0200)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/HA/Config.pm

index a9913da6e264f5392e4b4774a653b6f7bcb44893..1bb37a30e2091a5d8f931dfb007426bcb67d34cd 100644 (file)
@@ -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;