[PR #8222/524d5883 backport][stable-8] Avoid deprecated utcnow() (#8243)

Avoid deprecated utcnow() (#8222)

Avoid deprecated utcnow().

(cherry picked from commit 524d5883b8)

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
patchback[bot]
2024-04-20 10:21:02 +02:00
committed by GitHub
parent 83738f21a3
commit 4832100d76
19 changed files with 142 additions and 64 deletions

View File

@@ -75,13 +75,16 @@ RETURN = r'''
# Default return values
'''
import datetime
import ssl
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six.moves import xmlrpc_client
from ansible.module_utils.common.text.converters import to_text
from ansible_collections.community.general.plugins.module_utils.datetime import (
now,
)
def main():
module = AnsibleModule(
@@ -110,7 +113,7 @@ def main():
changed=True,
)
start = datetime.datetime.utcnow()
start = now()
ssl_context = None
if not validate_certs:
@@ -142,7 +145,7 @@ def main():
except Exception as e:
module.fail_json(msg="Failed to sync Cobbler. {error}".format(error=to_text(e)))
elapsed = datetime.datetime.utcnow() - start
elapsed = now() - start
module.exit_json(elapsed=elapsed.seconds, **result)