sensu-silence: fix json parsing of sensu API response (#1703) (#1717)

* sensu-silence: fix json parsing of sensu API response

* use ansible helper function to decode bytestream

* add changelog fragment

* Update changelogs, link to PR

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit b40a5ef09a)

Co-authored-by: Stefan Walluhn <stefan.walluhn@aboutsource.net>
pull/1719/head
patchback[bot] 2021-02-02 18:06:35 +01:00 committed by GitHub
parent 07b147d90f
commit be54f11a7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -0,0 +1,2 @@
bugfixes:
- sensu-silence module - fix json parsing of sensu API responses on Python 3.5 (https://github.com/ansible-collections/community.general/pull/1703).

View File

@ -97,6 +97,7 @@ RETURN = '''
import json
from ansible.module_utils._text import to_native
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.urls import fetch_url
@ -129,7 +130,7 @@ def query(module, url, check, subscription):
)
try:
json_out = json.loads(response.read())
json_out = json.loads(to_native(response.read()))
except Exception:
json_out = ""
@ -181,7 +182,7 @@ def clear(module, url, check, subscription):
)
try:
json_out = json.loads(response.read())
json_out = json.loads(to_native(response.read()))
except Exception:
json_out = ""
@ -246,7 +247,7 @@ def create(
)
try:
json_out = json.loads(response.read())
json_out = json.loads(to_native(response.read()))
except Exception:
json_out = ""