diff --git a/library/ceph_volume_simple_activate.py b/library/ceph_volume_simple_activate.py index 43efd9704..4825f0c82 100644 --- a/library/ceph_volume_simple_activate.py +++ b/library/ceph_volume_simple_activate.py @@ -16,6 +16,10 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible.module_utils.basic import AnsibleModule +try: + from ansible.module_utils.ca_common import exit_module +except ImportError: + from module_utils.ca_common import exit_module import datetime import os @@ -93,23 +97,6 @@ EXAMPLES = ''' RETURN = '''# ''' -def exit_module(module, out, rc, cmd, err, startd, changed=False): - endd = datetime.datetime.now() - delta = endd - startd - - result = dict( - cmd=cmd, - start=str(startd), - end=str(endd), - delta=str(delta), - rc=rc, - stdout=out.rstrip("\r\n"), - stderr=err.rstrip("\r\n"), - changed=changed, - ) - module.exit_json(**result) - - def main(): module = AnsibleModule( argument_spec=dict( diff --git a/library/ceph_volume_simple_scan.py b/library/ceph_volume_simple_scan.py index 5087d9aa5..e76f279a0 100644 --- a/library/ceph_volume_simple_scan.py +++ b/library/ceph_volume_simple_scan.py @@ -16,6 +16,10 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible.module_utils.basic import AnsibleModule +try: + from ansible.module_utils.ca_common import exit_module +except ImportError: + from module_utils.ca_common import exit_module import datetime import os @@ -85,23 +89,6 @@ EXAMPLES = ''' RETURN = '''# ''' -def exit_module(module, out, rc, cmd, err, startd, changed=False): - endd = datetime.datetime.now() - delta = endd - startd - - result = dict( - cmd=cmd, - start=str(startd), - end=str(endd), - delta=str(delta), - rc=rc, - stdout=out.rstrip("\r\n"), - stderr=err.rstrip("\r\n"), - changed=changed, - ) - module.exit_json(**result) - - def main(): module = AnsibleModule( argument_spec=dict( diff --git a/tests/library/test_ceph_volume_simple_activate.py b/tests/library/test_ceph_volume_simple_activate.py index 99fc62bb8..6f8a5ea3b 100644 --- a/tests/library/test_ceph_volume_simple_activate.py +++ b/tests/library/test_ceph_volume_simple_activate.py @@ -4,9 +4,7 @@ from ansible.module_utils._text import to_bytes import json import os import pytest -import sys -sys.path.append('./library') -import ceph_volume_simple_activate # noqa : E402 +import ceph_volume_simple_activate fake_cluster = 'ceph' fake_container_binary = 'podman' diff --git a/tests/library/test_ceph_volume_simple_scan.py b/tests/library/test_ceph_volume_simple_scan.py index 0dd8e9793..3dba9da13 100644 --- a/tests/library/test_ceph_volume_simple_scan.py +++ b/tests/library/test_ceph_volume_simple_scan.py @@ -4,9 +4,7 @@ from ansible.module_utils._text import to_bytes import json import os import pytest -import sys -sys.path.append('./library') -import ceph_volume_simple_scan # noqa : E402 +import ceph_volume_simple_scan fake_cluster = 'ceph' fake_container_binary = 'podman'