adapated to v2
This commit is contained in:
parent
10e5c2b46d
commit
a09f6236a5
1 changed files with 7 additions and 7 deletions
|
@ -20,13 +20,11 @@
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from ansible.callbacks import display
|
from ansible.plugins.callback import CallbackBase
|
||||||
|
|
||||||
|
|
||||||
# define start time
|
# define start time
|
||||||
t0 = tn = time.time()
|
t0 = tn = time.time()
|
||||||
|
|
||||||
|
|
||||||
def secondsToStr(t):
|
def secondsToStr(t):
|
||||||
# http://bytes.com/topic/python/answers/635958-handy-short-cut-formatting-elapsed-time-floating-point-seconds
|
# http://bytes.com/topic/python/answers/635958-handy-short-cut-formatting-elapsed-time-floating-point-seconds
|
||||||
rediv = lambda ll, b: list(divmod(ll[0], b)) + ll[1:]
|
rediv = lambda ll, b: list(divmod(ll[0], b)) + ll[1:]
|
||||||
|
@ -59,12 +57,15 @@ def tasktime():
|
||||||
tn = time.time()
|
tn = time.time()
|
||||||
|
|
||||||
|
|
||||||
class CallbackModule(object):
|
class CallbackModule(CallbackBase):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, display):
|
||||||
self.stats = {}
|
self.stats = {}
|
||||||
self.current = None
|
self.current = None
|
||||||
|
|
||||||
|
super(CallbackModule, self).__init__(display)
|
||||||
|
|
||||||
|
|
||||||
def playbook_on_task_start(self, name, is_conditional):
|
def playbook_on_task_start(self, name, is_conditional):
|
||||||
"""
|
"""
|
||||||
Logs the start of each task
|
Logs the start of each task
|
||||||
|
@ -97,10 +98,9 @@ class CallbackModule(object):
|
||||||
|
|
||||||
# Print the timings
|
# Print the timings
|
||||||
for name, elapsed in results:
|
for name, elapsed in results:
|
||||||
print(
|
self.display.display(
|
||||||
"{0:-<70}{1:->9}".format(
|
"{0:-<70}{1:->9}".format(
|
||||||
'{0} '.format(name),
|
'{0} '.format(name),
|
||||||
' {0:.02f}s'.format(elapsed),
|
' {0:.02f}s'.format(elapsed),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
print ''
|
|
||||||
|
|
Loading…
Reference in a new issue