[pve-devel] [RFC pve-ha-manager 5/8] TestHardware: add a more determinative delay possibility
Thomas Lamprecht
t.lamprecht at proxmox.com
Fri Dec 11 20:01:42 CET 2015
With this patch we can add a command to be executed after the
current command and some specified delay, e.g. the following
cmdlist line:
[ "power nodeX shutdown", "delay 5", "power nodeX on"]
This works more deterministic as it gets added to the helper
command list, which gets executed on every loop cycle from the
node processing loop and thus with a higher frequency,
whereas time between two comandlist commands can be undefined
and is mostly bigger. We need this for simulating a short power off
power on cycle.
Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
src/PVE/HA/Sim/TestHardware.pm | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/PVE/HA/Sim/TestHardware.pm b/src/PVE/HA/Sim/TestHardware.pm
index 5c8a0cd..300c300 100644
--- a/src/PVE/HA/Sim/TestHardware.pm
+++ b/src/PVE/HA/Sim/TestHardware.pm
@@ -290,12 +290,16 @@ sub run {
# end sumulation (500 seconds after last command)
return if (($self->{cur_time} - $last_command_time) > 500);
}
-
+ my $move_next_cmd_to_helpers;
foreach my $cmd (@$list) {
$last_command_time = $self->{cur_time};
if ($cmd =~ m/^delay\s+(\d+)\s*$/) {
$next_cmd_at = $self->{cur_time} + $1;
+ $move_next_cmd_to_helpers = 1;
+ } elsif ($move_next_cmd_to_helpers) {
+ &$add_helper_cmd($self, $next_cmd_at, $cmd);
+ $next_cmd_at = $self->{cur_time};
} else {
$self->sim_hardware_cmd($cmd, 'cmdlist');
}
--
2.1.4
More information about the pve-devel
mailing list