Merge "Use oslo_serialization instead of the json module directly"
This commit is contained in:
commit
618137b32f
|
@ -21,7 +21,7 @@ import oslo_messaging as messaging
|
|||
from oslo_log import log as logging
|
||||
from oslo_middleware import base
|
||||
from oslo_middleware import request_id
|
||||
from oslo_serialization import jsonutils as json
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import strutils
|
||||
|
||||
from designate import exceptions
|
||||
|
@ -130,7 +130,7 @@ class KeystoneContextMiddleware(ContextMiddleware):
|
|||
return flask.Response(status=401)
|
||||
|
||||
if headers.get('X-Service-Catalog'):
|
||||
catalog = json.loads(headers.get('X-Service-Catalog'))
|
||||
catalog = jsonutils.loads(headers.get('X-Service-Catalog'))
|
||||
else:
|
||||
catalog = None
|
||||
|
||||
|
@ -301,7 +301,7 @@ class FaultWrapperMiddleware(base.Middleware):
|
|||
LOG.error('Missing context in request, please check.')
|
||||
|
||||
return flask.Response(status=status, headers=headers,
|
||||
response=json.dumps(response))
|
||||
response=jsonutils.dump_as_bytes(response))
|
||||
|
||||
|
||||
class ValidationErrorMiddleware(base.Middleware):
|
||||
|
@ -352,7 +352,7 @@ class ValidationErrorMiddleware(base.Middleware):
|
|||
LOG.error('Missing context in request, please check.')
|
||||
|
||||
return flask.Response(status=exception.error_code, headers=headers,
|
||||
response=json.dumps(response))
|
||||
response=jsonutils.dump_as_bytes(response))
|
||||
|
||||
|
||||
class APIv2ValidationErrorMiddleware(ValidationErrorMiddleware):
|
||||
|
|
|
@ -13,12 +13,12 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import json
|
||||
import time
|
||||
|
||||
from eventlet import Timeout
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
import requests
|
||||
from requests.adapters import HTTPAdapter
|
||||
|
||||
|
@ -197,7 +197,7 @@ class DynClient(object):
|
|||
self._http_log_req(method, url, kwargs)
|
||||
|
||||
# NOTE: Set it back to the original data and serialize it.
|
||||
kwargs['data'] = json.dumps(data)
|
||||
kwargs['data'] = jsonutils.dump_as_bytes(data)
|
||||
else:
|
||||
self._http_log_req(method, url, kwargs)
|
||||
|
||||
|
|
|
@ -13,9 +13,8 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json as jsonutils
|
||||
|
||||
from oslo_log import log
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import strutils
|
||||
from six.moves.urllib import parse
|
||||
import requests
|
||||
|
@ -132,7 +131,7 @@ class Infoblox(object):
|
|||
|
||||
headers = {'Content-type': 'application/json'}
|
||||
|
||||
data = jsonutils.dumps(payload)
|
||||
data = jsonutils.dump_as_bytes(payload)
|
||||
url = self._construct_url(objtype, query_params, extattrs)
|
||||
|
||||
r = self.session.get(url,
|
||||
|
@ -175,7 +174,7 @@ class Infoblox(object):
|
|||
headers = {'Content-type': 'application/json'}
|
||||
|
||||
r = self.session.post(url,
|
||||
data=jsonutils.dumps(payload),
|
||||
data=jsonutils.dump_as_bytes(payload),
|
||||
verify=self.sslverify,
|
||||
headers=headers)
|
||||
|
||||
|
@ -203,7 +202,7 @@ class Infoblox(object):
|
|||
|
||||
headers = {'Content-type': 'application/json'}
|
||||
r = self.session.post(url,
|
||||
data=jsonutils.dumps(payload),
|
||||
data=jsonutils.dump_as_bytes(payload),
|
||||
verify=self.sslverify,
|
||||
headers=headers)
|
||||
|
||||
|
@ -232,7 +231,7 @@ class Infoblox(object):
|
|||
|
||||
headers = {'Content-type': 'application/json'}
|
||||
r = self.session.put(self._construct_url(ref),
|
||||
data=jsonutils.dumps(payload),
|
||||
data=jsonutils.dump_as_bytes(payload),
|
||||
verify=self.sslverify,
|
||||
headers=headers)
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import json as json_
|
||||
|
||||
from oslo_serialization import jsonutils
|
||||
from requests_mock.contrib import fixture as req_fixture
|
||||
import testtools
|
||||
|
||||
|
@ -136,7 +136,7 @@ class DynECTTestsCase(BackendTestCase):
|
|||
base_url = 'https://api.dynect.net:443/REST'
|
||||
|
||||
if json:
|
||||
kwargs['text'] = json_.dumps(json)
|
||||
kwargs['text'] = jsonutils.dumps(json)
|
||||
headers = kwargs.setdefault('headers', {})
|
||||
headers['Content-Type'] = 'application/json'
|
||||
|
||||
|
|
|
@ -13,9 +13,10 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import json
|
||||
import os
|
||||
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
from designate.tests import resources
|
||||
|
||||
|
||||
|
@ -29,5 +30,7 @@ class NotificationHandlerMixin(object):
|
|||
if not os.path.exists(filename):
|
||||
raise Exception('Invalid notification fixture requested')
|
||||
|
||||
with open(filename, 'r') as fh:
|
||||
return json.load(fh)
|
||||
with open(filename, 'r') as fp:
|
||||
fixture = fp.read()
|
||||
|
||||
return jsonutils.loads(fixture)
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import copy
|
||||
import json
|
||||
import functools
|
||||
import inspect
|
||||
import os
|
||||
|
@ -26,6 +25,7 @@ from jinja2 import Template
|
|||
from oslo_config import cfg
|
||||
from oslo_concurrency import processutils
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
from oslo_utils.netutils import is_valid_ipv6
|
||||
|
@ -150,7 +150,7 @@ def resource_string(*args):
|
|||
def load_schema(version, name):
|
||||
schema_string = resource_string('schemas', version, '%s.json' % name)
|
||||
|
||||
return json.loads(schema_string.decode('utf-8'))
|
||||
return jsonutils.loads(schema_string.decode('utf-8'))
|
||||
|
||||
|
||||
def load_template(template_name):
|
||||
|
|
Loading…
Reference in New Issue