Avoid deprecated utcnow() (#8222)

Avoid deprecated utcnow().
This commit is contained in:
Felix Fontein 2024-04-20 09:26:08 +02:00 committed by GitHub
parent 1b8e6bc95b
commit 524d5883b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 142 additions and 64 deletions

View file

@ -99,7 +99,6 @@ from ansible import context
import socket
import uuid
import logging
from datetime import datetime
try:
import logstash
@ -109,6 +108,10 @@ except ImportError:
from ansible.plugins.callback import CallbackBase
from ansible_collections.community.general.plugins.module_utils.datetime import (
now,
)
class CallbackModule(CallbackBase):
@ -126,7 +129,7 @@ class CallbackModule(CallbackBase):
"pip install python-logstash for Python 2"
"pip install python3-logstash for Python 3")
self.start_time = datetime.utcnow()
self.start_time = now()
def _init_plugin(self):
if not self.disabled:
@ -185,7 +188,7 @@ class CallbackModule(CallbackBase):
self.logger.info("ansible start", extra=data)
def v2_playbook_on_stats(self, stats):
end_time = datetime.utcnow()
end_time = now()
runtime = end_time - self.start_time
summarize_stat = {}
for host in stats.processed.keys():