1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-04-21 19:29:05 +00:00

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

* replace batch of redundant to_native() occurrences

* add changelog frag
This commit is contained in:
Alexei Znamensky 2025-11-11 19:10:00 +13:00 committed by GitHub
parent 6e1cc3eafd
commit 634be713bb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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 ""