summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohann Queuniet <sub_code.git@queuniet.fr>2018-11-27 16:42:10 +0100
committerToshio Kuratomi <a.badger@gmail.com>2019-01-09 14:44:30 -0800
commit011c0d59cb7305da71afa69408127a1d837218dd (patch)
tree6c93819f1303d8a4036a0b75ecfba0b895b85a1a
parent9ae95d52bcd1c8239f2440a36e5bc7a66fa747c3 (diff)
downloadansible-011c0d59cb7305da71afa69408127a1d837218dd.tar.gz
Convert URL output to a text/unicode string for json.loads
-rw-r--r--lib/ansible/modules/monitoring/grafana_dashboard.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/ansible/modules/monitoring/grafana_dashboard.py b/lib/ansible/modules/monitoring/grafana_dashboard.py
index 67f99e8433..262fe22002 100644
--- a/lib/ansible/modules/monitoring/grafana_dashboard.py
+++ b/lib/ansible/modules/monitoring/grafana_dashboard.py
@@ -141,6 +141,7 @@ import string
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.urls import fetch_url, url_argument_spec
from ansible.module_utils._text import to_native
+from ansible.module_utils._text import to_text
__metaclass__ = type
@@ -183,8 +184,10 @@ def get_grafana_version(module, grafana_url, headers):
r, info = fetch_url(module, '%s/api/frontend/settings' % grafana_url, headers=headers, method='GET')
if info['status'] == 200:
try:
- settings = json.loads(r.read())
+ settings = json.loads(to_text(r.read()))
grafana_version = settings['buildInfo']['version'].split('.')[0]
+ except UnicodeError as e:
+ raise GrafanaAPIException('Unable to decode version string to Unicode')
except Exception as e:
raise GrafanaAPIException(e)
else: