mirror of
https://github.com/ansible-collections/community.crypto.git
synced 2026-05-06 13:22:58 +00:00
Get rid of some to_native and to_text calls. (#880)
This commit is contained in:
@@ -554,7 +554,7 @@ import time
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||
from ansible.module_utils.common.text.converters import to_bytes, to_native
|
||||
from ansible.module_utils.common.text.converters import to_bytes
|
||||
from ansible_collections.community.crypto.plugins.module_utils.crypto.support import (
|
||||
load_certificate,
|
||||
)
|
||||
@@ -760,8 +760,7 @@ class EcsCertificate:
|
||||
self.cert_days = calculate_cert_days(self.cert_details.get("expiresAfter"))
|
||||
except RestOperationException as e:
|
||||
module.fail_json(
|
||||
f'Failed to get details of certificate with tracking_id="{self.tracking_id}", Error: ',
|
||||
to_native(e.message),
|
||||
msg=f'Failed to get details of certificate with tracking_id="{self.tracking_id}", Error: {e.message}'
|
||||
)
|
||||
|
||||
def check(self, module):
|
||||
|
||||
@@ -220,7 +220,6 @@ import datetime
|
||||
import time
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.common.text.converters import to_native
|
||||
from ansible_collections.community.crypto.plugins.module_utils.ecs.api import (
|
||||
ECSClient,
|
||||
RestOperationException,
|
||||
@@ -274,9 +273,7 @@ class EcsDomain:
|
||||
],
|
||||
)
|
||||
except SessionConfigurationException as e:
|
||||
module.fail_json(
|
||||
msg=f"Failed to initialize Entrust Provider: {to_native(e)}"
|
||||
)
|
||||
module.fail_json(msg=f"Failed to initialize Entrust Provider: {e}")
|
||||
try:
|
||||
self.ecs_client.GetAppVersion()
|
||||
except RestOperationException as e:
|
||||
|
||||
@@ -286,7 +286,6 @@ info:
|
||||
import os
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.common.text.converters import to_native
|
||||
from ansible_collections.community.crypto.plugins.module_utils.openssh.backends.common import (
|
||||
KeygenCommand,
|
||||
OpensshModule,
|
||||
@@ -381,7 +380,7 @@ class Certificate(OpensshModule):
|
||||
valid_to=self.module.params["valid_to"],
|
||||
)
|
||||
except ValueError as e:
|
||||
self.module.fail_json(msg=to_native(e))
|
||||
self.module.fail_json(msg=str(e))
|
||||
|
||||
def _execute(self):
|
||||
if self.state == "present":
|
||||
@@ -447,7 +446,7 @@ class Certificate(OpensshModule):
|
||||
valid_to=self.original_data.valid_before,
|
||||
)
|
||||
except ValueError as e:
|
||||
return self.module.fail_json(msg=to_native(e))
|
||||
return self.module.fail_json(msg=str(e))
|
||||
|
||||
if self.ignore_timestamps:
|
||||
return original_time_parameters.within_range(self.valid_at)
|
||||
@@ -463,7 +462,7 @@ class Certificate(OpensshModule):
|
||||
try:
|
||||
critical_options, extensions = parse_option_list(self.options)
|
||||
except ValueError as e:
|
||||
return self.module.fail_json(msg=to_native(e))
|
||||
return self.module.fail_json(msg=str(e))
|
||||
|
||||
return all(
|
||||
[
|
||||
@@ -528,9 +527,7 @@ class Certificate(OpensshModule):
|
||||
try:
|
||||
os.remove(self.path)
|
||||
except OSError as e:
|
||||
self.module.fail_json(
|
||||
msg=f"Unable to remove existing certificate: {to_native(e)}"
|
||||
)
|
||||
self.module.fail_json(msg=f"Unable to remove existing certificate: {e}")
|
||||
|
||||
@property
|
||||
def _result(self):
|
||||
|
||||
@@ -240,7 +240,6 @@ csr:
|
||||
|
||||
import os
|
||||
|
||||
from ansible.module_utils.common.text.converters import to_native
|
||||
from ansible_collections.community.crypto.plugins.module_utils.crypto.basic import (
|
||||
OpenSSLObjectError,
|
||||
)
|
||||
@@ -353,7 +352,7 @@ def main():
|
||||
result = csr.dump()
|
||||
module.exit_json(**result)
|
||||
except OpenSSLObjectError as exc:
|
||||
module.fail_json(msg=to_native(exc))
|
||||
module.fail_json(msg=str(exc))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -308,7 +308,6 @@ authority_cert_serial_number:
|
||||
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.common.text.converters import to_native
|
||||
from ansible_collections.community.crypto.plugins.module_utils.crypto.basic import (
|
||||
OpenSSLObjectError,
|
||||
)
|
||||
@@ -351,7 +350,7 @@ def main():
|
||||
result = module_backend.get_info()
|
||||
module.exit_json(**result)
|
||||
except OpenSSLObjectError as exc:
|
||||
module.fail_json(msg=to_native(exc))
|
||||
module.fail_json(msg=str(exc))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -127,7 +127,6 @@ csr:
|
||||
type: str
|
||||
"""
|
||||
|
||||
from ansible.module_utils.common.text.converters import to_native
|
||||
from ansible_collections.community.crypto.plugins.module_utils.crypto.basic import (
|
||||
OpenSSLObjectError,
|
||||
)
|
||||
@@ -183,7 +182,7 @@ def main():
|
||||
result = csr.dump()
|
||||
module.exit_json(**result)
|
||||
except OpenSSLObjectError as exc:
|
||||
module.fail_json(msg=to_native(exc))
|
||||
module.fail_json(msg=str(exc))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -212,7 +212,7 @@ class DHParameterBase:
|
||||
os.remove(self.path)
|
||||
self.changed = True
|
||||
except OSError as exc:
|
||||
module.fail_json(msg=to_native(exc))
|
||||
module.fail_json(msg=str(exc))
|
||||
|
||||
def check(self, module):
|
||||
"""Ensure the resource is in its desired state."""
|
||||
@@ -279,7 +279,7 @@ class DHParameterOpenSSL(DHParameterBase):
|
||||
command = [self.openssl_bin, "dhparam", "-out", tmpsrc, str(self.size)]
|
||||
rc, dummy, err = module.run_command(command, check_rc=False)
|
||||
if rc != 0:
|
||||
raise DHParameterError(to_native(err))
|
||||
raise DHParameterError(str(err))
|
||||
if self.backup:
|
||||
self.backup_file = module.backup_local(self.path)
|
||||
try:
|
||||
@@ -429,7 +429,7 @@ def main():
|
||||
try:
|
||||
dhparam.generate(module)
|
||||
except DHParameterError as exc:
|
||||
module.fail_json(msg=to_native(exc))
|
||||
module.fail_json(msg=str(exc))
|
||||
else:
|
||||
dhparam = DHParameterAbsent(module)
|
||||
|
||||
@@ -442,7 +442,7 @@ def main():
|
||||
try:
|
||||
dhparam.remove(module)
|
||||
except Exception as exc:
|
||||
module.fail_json(msg=to_native(exc))
|
||||
module.fail_json(msg=str(exc))
|
||||
|
||||
result = dhparam.dump()
|
||||
|
||||
|
||||
@@ -862,7 +862,7 @@ def main():
|
||||
|
||||
module.exit_json(**result)
|
||||
except OpenSSLObjectError as exc:
|
||||
module.fail_json(msg=to_native(exc))
|
||||
module.fail_json(msg=str(exc))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -156,7 +156,6 @@ privatekey:
|
||||
|
||||
import os
|
||||
|
||||
from ansible.module_utils.common.text.converters import to_native
|
||||
from ansible_collections.community.crypto.plugins.module_utils.crypto.basic import (
|
||||
OpenSSLObjectError,
|
||||
)
|
||||
@@ -287,7 +286,7 @@ def main():
|
||||
result = private_key.dump()
|
||||
module.exit_json(**result)
|
||||
except OpenSSLObjectError as exc:
|
||||
module.fail_json(msg=to_native(exc))
|
||||
module.fail_json(msg=str(exc))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -61,7 +61,6 @@ backup_file:
|
||||
|
||||
import os
|
||||
|
||||
from ansible.module_utils.common.text.converters import to_native
|
||||
from ansible_collections.community.crypto.plugins.module_utils.crypto.basic import (
|
||||
OpenSSLObjectError,
|
||||
)
|
||||
@@ -159,7 +158,7 @@ def main():
|
||||
result = private_key.dump()
|
||||
module.exit_json(**result)
|
||||
except OpenSSLObjectError as exc:
|
||||
module.fail_json(msg=to_native(exc))
|
||||
module.fail_json(msg=str(exc))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -200,7 +200,6 @@ private_data:
|
||||
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.common.text.converters import to_native
|
||||
from ansible_collections.community.crypto.plugins.module_utils.crypto.basic import (
|
||||
OpenSSLObjectError,
|
||||
)
|
||||
@@ -266,7 +265,7 @@ def main():
|
||||
result.update(exc.result)
|
||||
module.fail_json(msg=exc.error_message, **result)
|
||||
except OpenSSLObjectError as exc:
|
||||
module.fail_json(msg=to_native(exc))
|
||||
module.fail_json(msg=str(exc))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -187,7 +187,6 @@ import os
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||
from ansible.module_utils.common.text.converters import to_native
|
||||
from ansible_collections.community.crypto.plugins.module_utils.crypto.basic import (
|
||||
OpenSSLBadPassphraseError,
|
||||
OpenSSLObjectError,
|
||||
@@ -499,7 +498,7 @@ def main():
|
||||
result = public_key.dump()
|
||||
module.exit_json(**result)
|
||||
except OpenSSLObjectError as exc:
|
||||
module.fail_json(msg=to_native(exc))
|
||||
module.fail_json(msg=str(exc))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -152,7 +152,6 @@ public_data:
|
||||
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.common.text.converters import to_native
|
||||
from ansible_collections.community.crypto.plugins.module_utils.crypto.basic import (
|
||||
OpenSSLObjectError,
|
||||
)
|
||||
@@ -204,7 +203,7 @@ def main():
|
||||
result.update(exc.result)
|
||||
module.fail_json(msg=exc.error_message, **result)
|
||||
except OpenSSLObjectError as exc:
|
||||
module.fail_json(msg=to_native(exc))
|
||||
module.fail_json(msg=str(exc))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -120,7 +120,6 @@ else:
|
||||
CRYPTOGRAPHY_FOUND = True
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||
from ansible.module_utils.common.text.converters import to_native
|
||||
from ansible_collections.community.crypto.plugins.module_utils.crypto.basic import (
|
||||
OpenSSLObjectError,
|
||||
)
|
||||
@@ -280,7 +279,7 @@ def main():
|
||||
|
||||
module.exit_json(**result)
|
||||
except OpenSSLObjectError as exc:
|
||||
module.fail_json(msg=to_native(exc))
|
||||
module.fail_json(msg=str(exc))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -109,7 +109,6 @@ else:
|
||||
CRYPTOGRAPHY_FOUND = True
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||
from ansible.module_utils.common.text.converters import to_native
|
||||
from ansible_collections.community.crypto.plugins.module_utils.crypto.basic import (
|
||||
OpenSSLObjectError,
|
||||
)
|
||||
@@ -285,7 +284,7 @@ def main():
|
||||
|
||||
module.exit_json(**result)
|
||||
except OpenSSLObjectError as exc:
|
||||
module.fail_json(msg=to_native(exc))
|
||||
module.fail_json(msg=str(exc))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -225,7 +225,6 @@ certificate:
|
||||
|
||||
import os
|
||||
|
||||
from ansible.module_utils.common.text.converters import to_native
|
||||
from ansible_collections.community.crypto.plugins.module_utils.crypto.basic import (
|
||||
OpenSSLObjectError,
|
||||
)
|
||||
@@ -405,7 +404,7 @@ def main():
|
||||
result = certificate.dump()
|
||||
module.exit_json(**result)
|
||||
except OpenSSLObjectError as exc:
|
||||
module.fail_json(msg=to_native(exc))
|
||||
module.fail_json(msg=str(exc))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -109,7 +109,7 @@ import os
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||
from ansible.module_utils.common.text.converters import to_bytes, to_native, to_text
|
||||
from ansible.module_utils.common.text.converters import to_bytes, to_text
|
||||
from ansible_collections.community.crypto.plugins.module_utils.crypto.basic import (
|
||||
OpenSSLObjectError,
|
||||
)
|
||||
@@ -317,7 +317,7 @@ def main():
|
||||
result = cert.dump()
|
||||
module.exit_json(**result)
|
||||
except OpenSSLObjectError as exc:
|
||||
module.fail_json(msg=to_native(exc))
|
||||
module.fail_json(msg=str(exc))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -390,7 +390,6 @@ issuer_uri:
|
||||
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.common.text.converters import to_native
|
||||
from ansible_collections.community.crypto.plugins.module_utils.crypto.basic import (
|
||||
OpenSSLObjectError,
|
||||
)
|
||||
@@ -462,7 +461,7 @@ def main():
|
||||
|
||||
module.exit_json(**result)
|
||||
except OpenSSLObjectError as exc:
|
||||
module.fail_json(msg=to_native(exc))
|
||||
module.fail_json(msg=str(exc))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -118,8 +118,6 @@ certificate:
|
||||
type: str
|
||||
"""
|
||||
|
||||
|
||||
from ansible.module_utils.common.text.converters import to_native
|
||||
from ansible_collections.community.crypto.plugins.module_utils.crypto.basic import (
|
||||
OpenSSLObjectError,
|
||||
)
|
||||
@@ -197,7 +195,7 @@ def main():
|
||||
result = certificate.dump()
|
||||
module.exit_json(**result)
|
||||
except OpenSSLObjectError as exc:
|
||||
module.fail_json(msg=to_native(exc))
|
||||
module.fail_json(msg=str(exc))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -429,7 +429,7 @@ import os
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||
from ansible.module_utils.common.text.converters import to_native, to_text
|
||||
from ansible.module_utils.common.text.converters import to_text
|
||||
from ansible.module_utils.common.validation import check_type_int, check_type_str
|
||||
from ansible_collections.community.crypto.plugins.module_utils.crypto.basic import (
|
||||
OpenSSLBadPassphraseError,
|
||||
@@ -543,7 +543,7 @@ class CRL(OpenSSLObject):
|
||||
self.issuer_ordered = False
|
||||
self.issuer = parse_name_field(module.params["issuer"], "issuer")
|
||||
except (TypeError, ValueError) as exc:
|
||||
module.fail_json(msg=to_native(exc))
|
||||
module.fail_json(msg=str(exc))
|
||||
|
||||
self.last_update = get_relative_time_option(
|
||||
module.params["last_update"],
|
||||
@@ -1040,7 +1040,7 @@ def main():
|
||||
result = crl.dump()
|
||||
module.exit_json(**result)
|
||||
except OpenSSLObjectError as exc:
|
||||
module.fail_json(msg=to_native(exc))
|
||||
module.fail_json(msg=str(exc))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -175,7 +175,6 @@ import base64
|
||||
import binascii
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.common.text.converters import to_native
|
||||
from ansible_collections.community.crypto.plugins.module_utils.crypto.basic import (
|
||||
OpenSSLObjectError,
|
||||
)
|
||||
@@ -224,7 +223,7 @@ def main():
|
||||
)
|
||||
module.exit_json(**result)
|
||||
except OpenSSLObjectError as e:
|
||||
module.fail_json(msg=to_native(e))
|
||||
module.fail_json(msg=str(e))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user