From c2b7cbca4fac116daa63f7e99443ad71351b954c Mon Sep 17 00:00:00 2001 From: Alejandro Huertas Herrero Date: Thu, 17 Feb 2022 16:16:40 +0100 Subject: [PATCH] B #4552: fix bug in CLI charters (#1785) (cherry picked from commit 782e225219c6ddb8156e143c957c31b52f8eedca) --- src/cli/onevm | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/cli/onevm b/src/cli/onevm index ed0622f1bb..2e062c0034 100755 --- a/src/cli/onevm +++ b/src/cli/onevm @@ -1398,16 +1398,22 @@ CommandParser::CmdParser.new(ARGV) do acc_t = 0 acc_w = 0 - charters.each do |action, time| - sched = "+#{time[:time].to_i + acc_t}" + helper.perform_action(args[0], {}, 'Charter added') do |vm| + vm.info - helper.schedule_actions([args[0]].flatten, - { :schedule => sched }, - action.to_s, - time[:warning][:time] + acc_w) + diff_stime = Time.now.to_i - vm['/VM/STIME'].to_i - acc_t += time[:time].to_i - acc_w += time[:warning][:time].to_i + charters.each do |action, time| + sched = "+#{time[:time].to_i + acc_t + diff_stime}" + + helper.schedule_actions([args[0]].flatten, + { :schedule => sched }, + action.to_s, + time[:warning][:time] + acc_w) + + acc_t += time[:time].to_i + acc_w += time[:warning][:time].to_i + end end 0