]> git.proxmox.com Git - pve-ha-manager.git/commitdiff
lrm: introduce disabled state
authorDietmar Maurer <dietmar@proxmox.com>
Fri, 13 Mar 2015 14:37:58 +0000 (15:37 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 13 Mar 2015 14:37:58 +0000 (15:37 +0100)
src/PVE/HA/LRM.pm

index 928e1de727660f945831a6e508d3793ef5d4f39a..b2a79c6881e6e65b1bfbc2002c8fe9500a8048b5 100644 (file)
@@ -14,7 +14,8 @@ use PVE::HA::Tools;
 # Server can have several states:
 
 my $valid_states = {
-    wait_for_agent_lock => "waiting for agnet lock",
+    disabled => "HA is disabled (no resource configuration)",
+    wait_for_agent_lock => "waiting for agent lock",
     active => "got agent_lock",
     lost_agent_lock => "lost agent_lock",
 };
@@ -31,7 +32,10 @@ sub new {
        results => {},
     }, $class;
 
-    $self->set_local_status({ state => 'wait_for_agent_lock' });   
+    my $next_state = $haenv->service_config_exists() ?
+       'wait_for_agent_lock' : 'disabled';
+    
+    $self->set_local_status({ state => $next_state });   
     
     return $self;
 }
@@ -110,7 +114,13 @@ sub do_one_iteration {
 
     my $ctime = $haenv->get_time();
 
-    if ($state eq 'wait_for_agent_lock') {
+    if ($state eq 'disabled') {
+
+       if ($haenv->service_config_exists()) {
+           $self->set_local_status({ state => 'wait_for_agent_lock' });
+       }
+       
+    } if ($state eq 'wait_for_agent_lock') {
 
        my $service_count = 1; # todo: correctly compute
 
@@ -217,7 +227,10 @@ sub do_one_iteration {
 
            return 0;
        }
+    } elsif ($state eq 'disabled') {
 
+       # do nothing
+       
     } else {
 
        die "got unexpected status '$state'\n";