json module replaced with jsonutils

Now for operations with JSON data jsonutils module from
oslo.serialization package is used. Depends on patch [1] to fuel-main.

[1]: https://review.openstack.org/#/c/143639/

Change-Id: If872d46fc23eb71860f3e6b8508eef7ce7b4f223
Closes-Bug: #1404856
This commit is contained in:
Artem Roma 2014-12-22 16:27:58 +02:00
parent b9a090c716
commit 1c8ed01da9
7 changed files with 23 additions and 20 deletions

View File

@ -13,8 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import json
import logging
from oslo.serialization import jsonutils
import requests
import fuel_health.common.ssh
@ -110,8 +110,8 @@ class GlanceTest(fuel_health.nmanager.NovaNetworkScenarioTest):
if client == self.glance_client_v1:
for group in object.properties:
if group == group_props:
for i in json.loads(object.properties[group]):
k = json.loads(object.properties[group])[prop]
for i in jsonutils.loads(object.properties[group]):
k = jsonutils.loads(object.properties[group])[prop]
if i == prop and k == unicode(value_prop):
return 'OK'
else:

View File

@ -13,11 +13,12 @@
# License for the specific language governing permissions and limitations
# under the License.
import json
import logging
import time
import traceback
from oslo.serialization import jsonutils
import muranoclient.common.exceptions as exceptions
import requests
@ -80,7 +81,7 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
for image in self.compute_client.images.list():
if tag in image.metadata:
metadata = json.loads(image.metadata[tag])
metadata = jsonutils.loads(image.metadata[tag])
if image_type == metadata['type']:
return image
@ -105,7 +106,7 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
post_body = {'name': name}
resp = requests.post(self.endpoint + 'environments',
data=json.dumps(post_body),
data=jsonutils.dumps(post_body),
headers=self.headers)
return resp.json()
@ -215,7 +216,7 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
headers.update({'x-configuration-session': session_id})
endpoint = '{0}environments/{1}/services'.format(self.endpoint,
environment_id)
return requests.post(endpoint, data=json.dumps(json_data),
return requests.post(endpoint, data=jsonutils.dumps(json_data),
headers=headers).json()
def list_services(self, environment_id, session_id=None):

View File

@ -12,19 +12,19 @@
# License for the specific language governing permissions and limitations
# under the License.
from distutils import version
import itertools
import json
import logging
import multiprocessing
import os
import re
import traceback
from distutils import version
from nose import case
from nose.suite import ContextSuite
from oslo.serialization import jsonutils
LOG = logging.getLogger(__name__)
@ -33,7 +33,7 @@ def parse_json_file(file_path):
commands_path = os.path.join(
current_directory, file_path)
with open(commands_path, 'r') as f:
return json.load(f)
return jsonutils.load(f)
def get_exc_message(exception_value):

View File

@ -12,23 +12,23 @@
# License for the specific language governing permissions and limitations
# under the License.
import json
from sqlalchemy.types import TypeDecorator, VARCHAR
from oslo.serialization import jsonutils
class JsonField(TypeDecorator):
impl = VARCHAR
def process_bind_param(self, value, dialect):
if value is not None:
value = json.dumps(value)
value = jsonutils.dumps(value)
return value
def process_result_value(self, value, dialect):
if value is not None:
value = json.loads(value)
value = jsonutils.loads(value)
return value

View File

@ -12,10 +12,10 @@
# License for the specific language governing permissions and limitations
# under the License.
import json
import logging
from oslo.config import cfg
from oslo.serialization import jsonutils
from pecan import abort
from pecan import expose
from pecan import request
@ -123,7 +123,7 @@ class TestrunsController(BaseRestController):
@expose('json')
def post(self):
test_runs = json.loads(request.body)
test_runs = jsonutils.loads(request.body)
if 'objects' in test_runs:
test_runs = test_runs['objects']
@ -170,7 +170,7 @@ class TestrunsController(BaseRestController):
@expose('json')
def put(self):
test_runs = json.loads(request.body)
test_runs = jsonutils.loads(request.body)
if 'objects' in test_runs:
test_runs = test_runs['objects']

View File

@ -12,10 +12,11 @@
# License for the specific language governing permissions and limitations
# under the License.
import json
import requests
import time
from oslo.serialization import jsonutils
class TestingAdapterClient(object):
def __init__(self, url):
@ -38,7 +39,7 @@ class TestingAdapterClient(object):
else:
data_el['ostf_os_access_creds'] = ostf_os_access_creds
data = json.dumps({'objects': data})
data = jsonutils.dumps({'objects': data})
r = requests.request(
method,

View File

@ -21,6 +21,7 @@ gevent==0.13.8
importlib
keystonemiddleware>=1.2.0
kombu
oslo.serialization>=1.0.0
pecan>=0.3.0,<0.6.0
psycopg2>=2.5.1
stevedore>=0.10