]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/tasks/barbican.py: convert to str before json.loads()
authorKefu Chai <kchai@redhat.com>
Mon, 6 Apr 2020 09:36:18 +0000 (17:36 +0800)
committerKefu Chai <kchai@redhat.com>
Sun, 14 Jun 2020 08:34:53 +0000 (16:34 +0800)
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 <kchai@redhat.com>
(cherry picked from commit c79e1e1a525e08d55fd60c2333e8f5d4df603350)

qa/tasks/barbican.py

index b6b455e5fc2590bd4f33c5af4571977fdd34db35..46b036ef4ced680dc80421721ec1ad45fb0183fa 100644 (file)
@@ -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
@@ -357,7 +358,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"]