From: Kefu Chai Date: Mon, 6 Apr 2020 09:36:18 +0000 (+0800) Subject: qa/tasks/barbican.py: convert to str before json.loads() X-Git-Tag: wip-pdonnell-testing-20200918.022351~1585^2~18 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=c79e1e1a525e08d55fd60c2333e8f5d4df603350;p=ceph-ci.git qa/tasks/barbican.py: convert to str before json.loads() in Python3, json.loads() expects a string, while HTTPConnection.getresponse() returns a byte-like object, so we need to coerce it to str first. Signed-off-by: Kefu Chai --- diff --git a/qa/tasks/barbican.py b/qa/tasks/barbican.py index 51a9af1f9eb..6c7f97376ec 100644 --- a/qa/tasks/barbican.py +++ b/qa/tasks/barbican.py @@ -4,6 +4,7 @@ Deploy and configure Barbican for Teuthology import argparse import contextlib import logging +import six from six.moves import http_client from six.moves.urllib.parse import urlparse import json @@ -271,7 +272,7 @@ def create_secrets(ctx, config): rgw_access_user_resp.status < 300): raise Exception("Cannot authenticate user "+rgw_user["username"]+" for secret creation") # baru_resp = json.loads(baru_req.data) - rgw_access_user_data = json.loads(rgw_access_user_resp.read()) + rgw_access_user_data = json.loads(six.ensure_str(rgw_access_user_resp.read())) rgw_user_id = rgw_access_user_data['access']['user']['id'] if 'secrets' in cconfig: @@ -309,7 +310,7 @@ def create_secrets(ctx, config): token_resp.status < 300): raise Exception("Cannot authenticate user "+secret["username"]+" for secret creation") - token_data = json.loads(token_resp.read()) + token_data = json.loads(six.ensure_str(token_resp.read())) token_id = token_data['access']['token']['id'] key1_json = json.dumps( @@ -342,7 +343,7 @@ def create_secrets(ctx, config): if not (barbican_sec_resp.status >= 200 and barbican_sec_resp.status < 300): raise Exception("Cannot create secret") - barbican_data = json.loads(barbican_sec_resp.read()) + barbican_data = json.loads(six.ensure_str(barbican_sec_resp.read())) if 'secret_ref' not in barbican_data: raise ValueError("Malformed secret creation response") secret_ref = barbican_data["secret_ref"]