[PR #11098/634be713 backport][stable-12] replace batch of redundant to_native() occurrences (#11100)

replace batch of redundant to_native() occurrences (#11098)

* replace batch of redundant to_native() occurrences

* add changelog frag

(cherry picked from commit 634be713bb)

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
patchback[bot]
2025-11-11 07:23:07 +01:00
committed by GitHub
parent 5be39ee0c3
commit d487734fea
63 changed files with 164 additions and 157 deletions

View File

@@ -104,7 +104,6 @@ import json
from ansible.module_utils.urls import ConnectionError
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.common.text.converters import to_native
import ansible_collections.community.general.plugins.module_utils.influxdb as influx
@@ -118,7 +117,7 @@ def find_user(module, client, user_name):
user_result = user
break
except ConnectionError as e:
module.fail_json(msg=to_native(e))
module.fail_json(msg=f"{e}")
return user_result
@@ -130,7 +129,7 @@ def check_user_password(module, client, user_name, user_password):
if e.code == 401:
return False
except ConnectionError as e:
module.fail_json(msg=to_native(e))
module.fail_json(msg=f"{e}")
finally:
# restore previous user
client.switch_user(module.params["username"], module.params["password"])
@@ -142,7 +141,7 @@ def set_user_password(module, client, user_name, user_password):
try:
client.set_user_password(user_name, user_password)
except ConnectionError as e:
module.fail_json(msg=to_native(e))
module.fail_json(msg=f"{e}")
def create_user(module, client, user_name, user_password, admin):
@@ -150,7 +149,7 @@ def create_user(module, client, user_name, user_password, admin):
try:
client.create_user(user_name, user_password, admin)
except ConnectionError as e:
module.fail_json(msg=to_native(e))
module.fail_json(msg=f"{e}")
def drop_user(module, client, user_name):
@@ -234,12 +233,12 @@ def main():
msg = json.loads(e.content)
reason = msg["error"]
except (KeyError, ValueError):
module.fail_json(msg=to_native(e))
module.fail_json(msg=f"{e}")
if reason != INFLUX_AUTH_FIRST_USER_REQUIRED:
module.fail_json(msg=to_native(e))
module.fail_json(msg=f"{e}")
else:
module.fail_json(msg=to_native(e))
module.fail_json(msg=f"{e}")
changed = False
@@ -259,7 +258,7 @@ def main():
client.revoke_admin_privileges(user_name)
changed = True
except influx.exceptions.InfluxDBClientError as e:
module.fail_json(msg=to_native(e))
module.fail_json(msg=f"{e}")
else:
user_password = user_password or ""