[pve-devel] [RFC v2 pve-ha-manager 2/9] Sim/Hardware: change online computation of node slightly

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Dec 14 15:29:54 CET 2015


Mark a node during Testruns online if both, network and power,
are in the following states:
*) on - (obvious)
*) shutdown or restart - this allows the simulation of graceful
   shutdowns and restarts, as we need to be quorate until we're
   really powered of.

This is preparation work for adding a shutdown and restart power
action to the hardware.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 src/PVE/HA/Sim/Hardware.pm | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/PVE/HA/Sim/Hardware.pm b/src/PVE/HA/Sim/Hardware.pm
index 24ef68b..c563675 100644
--- a/src/PVE/HA/Sim/Hardware.pm
+++ b/src/PVE/HA/Sim/Hardware.pm
@@ -342,7 +342,12 @@ my $compute_node_info = sub {
     foreach my $node (keys %$cstatus) {
 	my $d = $cstatus->{$node};
 
-	my $online = ($d->{power} eq 'on' && $d->{network} eq 'on') ? 1 : 0;
+	my $online;
+	if (($d->{power} eq 'on' && $d->{network} eq 'on') ||
+	    ($d->{power} eq 'restart' && $d->{network} eq 'restart') ||
+	    ($d->{power} eq 'shutdown' && $d->{network} eq 'shutdown')) {
+	    $online = 1;
+	}
 	$node_info->{$node}->{online} = $online;
 
 	$node_count++;
-- 
2.1.4




More information about the pve-devel mailing list