From ec911edd292ec0a008399951c33674e3b5f6bfe8 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Fri, 13 Mar 2015 15:37:58 +0100 Subject: [PATCH] lrm: introduce disabled state --- src/PVE/HA/LRM.pm | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/PVE/HA/LRM.pm b/src/PVE/HA/LRM.pm index 928e1de..b2a79c6 100644 --- a/src/PVE/HA/LRM.pm +++ b/src/PVE/HA/LRM.pm @@ -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"; -- 2.39.2