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
This commit is contained in:
parent
6f0462e4ee
commit
d9a8de9e90
@ -14,13 +14,11 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
try:
|
|
||||||
import json
|
|
||||||
except ImportError:
|
|
||||||
import simplejson as json
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
|
|
||||||
from keystoneclient import access
|
from keystoneclient import access
|
||||||
from keystoneclient import adapter
|
from keystoneclient import adapter
|
||||||
import requests
|
import requests
|
||||||
@ -209,14 +207,14 @@ class HTTPClient(object):
|
|||||||
|
|
||||||
token_url = self.auth_url + "/tokens"
|
token_url = self.auth_url + "/tokens"
|
||||||
resp, resp_body = self._cs_request(token_url, "POST",
|
resp, resp_body = self._cs_request(token_url, "POST",
|
||||||
body=json.dumps(body),
|
body=jsonutils.dumps(body),
|
||||||
content_type="application/json",
|
content_type="application/json",
|
||||||
allow_redirects=True)
|
allow_redirects=True)
|
||||||
if resp.status_code != 200:
|
if resp.status_code != 200:
|
||||||
raise exceptions.Unauthorized(message=resp_body)
|
raise exceptions.Unauthorized(message=resp_body)
|
||||||
if resp_body:
|
if resp_body:
|
||||||
try:
|
try:
|
||||||
resp_body = json.loads(resp_body)
|
resp_body = jsonutils.loads(resp_body)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
@ -252,7 +250,7 @@ class HTTPClient(object):
|
|||||||
self.authenticate()
|
self.authenticate()
|
||||||
return self.endpoint_url
|
return self.endpoint_url
|
||||||
|
|
||||||
body = json.loads(body)
|
body = jsonutils.loads(body)
|
||||||
for endpoint in body.get('endpoints', []):
|
for endpoint in body.get('endpoints', []):
|
||||||
if (endpoint['type'] == 'mec-orchestration' and
|
if (endpoint['type'] == 'mec-orchestration' and
|
||||||
endpoint.get('region') == self.region_name):
|
endpoint.get('region') == self.region_name):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user