timer callback plugin: handle timezone changes better
A playbook that does `timezone name=Australia/Brisbane` on a host previously in UTC will appear to take 10 hours. Improve the seconds handling for playbooks that take longer than one hour. Improve the hours handling for playbooks that take longer than one day. TZ change before: ``` Playbook run took 0 days, 10 hours, 0 minutes, 36055 seconds ``` After: ``` Playbook run took 0 days, 0 hours, 0 minutes, 55 seconds ``` Sleep for 100s more than one hour before: ``` Playbook run took 0 days, 1 hours, 1 minutes, 3641 seconds ``` After: ``` Playbook run took 0 days, 1 hours, 1 minutes, 41 seconds ```
This commit is contained in:
parent
f17cb253a4
commit
11da85f938
1 changed files with 3 additions and 3 deletions
|
@ -20,17 +20,17 @@ class CallbackModule(CallbackBase):
|
|||
|
||||
super(CallbackModule, self).__init__()
|
||||
|
||||
self.start_time = datetime.now()
|
||||
self.start_time = datetime.utcnow()
|
||||
|
||||
def days_hours_minutes_seconds(self, runtime):
|
||||
minutes = (runtime.seconds // 60) % 60
|
||||
r_seconds = runtime.seconds - (minutes * 60)
|
||||
r_seconds = runtime.seconds % 60
|
||||
return runtime.days, runtime.seconds // 3600, minutes, r_seconds
|
||||
|
||||
def playbook_on_stats(self, stats):
|
||||
self.v2_playbook_on_stats(stats)
|
||||
|
||||
def v2_playbook_on_stats(self, stats):
|
||||
end_time = datetime.now()
|
||||
end_time = datetime.utcnow()
|
||||
runtime = end_time - self.start_time
|
||||
self._display.display("Playbook run took %s days, %s hours, %s minutes, %s seconds" % (self.days_hours_minutes_seconds(runtime)))
|
||||
|
|
Loading…
Reference in a new issue