From d9a8de9e9085ce75c64f07ee23706e8ee9eba576 Mon Sep 17 00:00:00 2001 From: "cao.yuan" Date: Sun, 24 Feb 2019 23:36:39 +0800 Subject: [PATCH] Update json module to jsonutils oslo project provide jsonutils, and apmecclient use it in many place[1], this PS to update the remained json moudule to oslo jsonutils for consistency. [1]: https://github.com/openstack/python-apmecclient/search?utf8=%E2%9C%93&q=jsonutils&type= Change-Id: Id6e3a1d64a54a9858041597c2cda414407f1edb1 --- apmecclient/client.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/apmecclient/client.py b/apmecclient/client.py index 84cdb90..a150275 100644 --- a/apmecclient/client.py +++ b/apmecclient/client.py @@ -14,13 +14,11 @@ # under the License. # -try: - import json -except ImportError: - import simplejson as json import logging import os +from oslo_serialization import jsonutils + from keystoneclient import access from keystoneclient import adapter import requests @@ -209,14 +207,14 @@ class HTTPClient(object): token_url = self.auth_url + "/tokens" resp, resp_body = self._cs_request(token_url, "POST", - body=json.dumps(body), + body=jsonutils.dumps(body), content_type="application/json", allow_redirects=True) if resp.status_code != 200: raise exceptions.Unauthorized(message=resp_body) if resp_body: try: - resp_body = json.loads(resp_body) + resp_body = jsonutils.loads(resp_body) except ValueError: pass else: @@ -252,7 +250,7 @@ class HTTPClient(object): self.authenticate() return self.endpoint_url - body = json.loads(body) + body = jsonutils.loads(body) for endpoint in body.get('endpoints', []): if (endpoint['type'] == 'mec-orchestration' and endpoint.get('region') == self.region_name):