Update json module to jsonutils
oslo project provide jsonutils, and octavia use it in many place[1], this PS to update the remained json moudule to oslo jsonutils for consistency. [1]: https://github.com/openstack/octavia-tempest-plugin/search?utf8=%E2%9C%93&q=jsonutils&type= Change-Id: I1cf966595bbabd3e33b1e33033dfb6a8b16381f8
This commit is contained in:
parent
6b03191c92
commit
45e6e66823
@ -12,7 +12,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
from tempest import config
|
||||
|
||||
@ -154,6 +154,6 @@ class AmphoraClient(base_client.BaseLBaaSClient):
|
||||
response, body = self.get(request_uri)
|
||||
self.expected_success(200, response.status)
|
||||
if return_object_only:
|
||||
return json.loads(body.decode('utf-8'))[self.stats_root_tag]
|
||||
return jsonutils.loads(body.decode('utf-8'))[self.stats_root_tag]
|
||||
else:
|
||||
return json.loads(body.decode('utf-8'))
|
||||
return jsonutils.loads(body.decode('utf-8'))
|
||||
|
@ -13,9 +13,8 @@
|
||||
# under the License.
|
||||
#
|
||||
|
||||
import json
|
||||
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
from tempest import config
|
||||
from tempest.lib.common import rest_client
|
||||
from tempest.lib.common.utils import test_utils
|
||||
@ -99,12 +98,12 @@ class BaseLBaaSClient(rest_client.RestClient):
|
||||
else:
|
||||
request_uri = self.uri
|
||||
|
||||
response, body = self.post(request_uri, json.dumps(obj_dict))
|
||||
response, body = self.post(request_uri, jsonutils.dumps(obj_dict))
|
||||
self.expected_success(201, response.status)
|
||||
if return_object_only:
|
||||
return json.loads(body.decode('utf-8'))[self.root_tag]
|
||||
return jsonutils.loads(body.decode('utf-8'))[self.root_tag]
|
||||
else:
|
||||
return json.loads(body.decode('utf-8'))
|
||||
return jsonutils.loads(body.decode('utf-8'))
|
||||
|
||||
def _show_object(self, obj_id, parent_id=None, query_params=None,
|
||||
return_object_only=True):
|
||||
@ -156,9 +155,9 @@ class BaseLBaaSClient(rest_client.RestClient):
|
||||
response, body = self.get(request_uri)
|
||||
self.expected_success(200, response.status)
|
||||
if return_object_only:
|
||||
return json.loads(body.decode('utf-8'))[self.root_tag]
|
||||
return jsonutils.loads(body.decode('utf-8'))[self.root_tag]
|
||||
else:
|
||||
return json.loads(body.decode('utf-8'))
|
||||
return jsonutils.loads(body.decode('utf-8'))
|
||||
|
||||
def _list_objects(self, parent_id=None, query_params=None,
|
||||
return_object_only=True):
|
||||
@ -208,9 +207,9 @@ class BaseLBaaSClient(rest_client.RestClient):
|
||||
response, body = self.get(request_uri)
|
||||
self.expected_success(200, response.status)
|
||||
if return_object_only:
|
||||
return json.loads(body.decode('utf-8'))[self.list_root_tag]
|
||||
return jsonutils.loads(body.decode('utf-8'))[self.list_root_tag]
|
||||
else:
|
||||
return json.loads(body.decode('utf-8'))
|
||||
return jsonutils.loads(body.decode('utf-8'))
|
||||
|
||||
def _update_object(self, obj_id, parent_id=None, return_object_only=True,
|
||||
**kwargs):
|
||||
@ -258,12 +257,12 @@ class BaseLBaaSClient(rest_client.RestClient):
|
||||
uri = self.uri
|
||||
|
||||
request_uri = '{0}/{1}'.format(uri, obj_id)
|
||||
response, body = self.put(request_uri, json.dumps(obj_dict))
|
||||
response, body = self.put(request_uri, jsonutils.dumps(obj_dict))
|
||||
self.expected_success(200, response.status)
|
||||
if return_object_only:
|
||||
return json.loads(body.decode('utf-8'))[self.root_tag]
|
||||
return jsonutils.loads(body.decode('utf-8'))[self.root_tag]
|
||||
else:
|
||||
return json.loads(body.decode('utf-8'))
|
||||
return jsonutils.loads(body.decode('utf-8'))
|
||||
|
||||
def _delete_obj(self, obj_id, parent_id=None, ignore_errors=False,
|
||||
cascade=False):
|
||||
@ -365,7 +364,7 @@ class BaseLBaaSClient(rest_client.RestClient):
|
||||
try:
|
||||
request_uri = '{0}/{1}'.format(uri, obj_id)
|
||||
response, body = self.get(request_uri)
|
||||
resp_obj = json.loads(body.decode('utf-8'))[self.root_tag]
|
||||
resp_obj = jsonutils.loads(body.decode('utf-8'))[self.root_tag]
|
||||
if (response.status == 404 or
|
||||
resp_obj['provisioning_status'] == const.DELETED):
|
||||
raise exceptions.NotFound()
|
||||
@ -447,7 +446,7 @@ class BaseLBaaSClient(rest_client.RestClient):
|
||||
response, body = self.get('/')
|
||||
self.expected_success(200, response.status)
|
||||
|
||||
versions_list = json.loads(body.decode('utf-8'))['versions']
|
||||
versions_list = jsonutils.loads(body.decode('utf-8'))['versions']
|
||||
current_versions = (version for version in versions_list if
|
||||
version['status'] == 'CURRENT')
|
||||
max_version = '0.0'
|
||||
|
@ -13,7 +13,7 @@
|
||||
# under the License.
|
||||
#
|
||||
|
||||
import json
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
from tempest import config
|
||||
|
||||
@ -340,6 +340,6 @@ class ListenerClient(base_client.BaseLBaaSClient):
|
||||
response, body = self.get(request_uri)
|
||||
self.expected_success(200, response.status)
|
||||
if return_object_only:
|
||||
return json.loads(body.decode('utf-8'))['stats']
|
||||
return jsonutils.loads(body.decode('utf-8'))['stats']
|
||||
else:
|
||||
return json.loads(body.decode('utf-8'))
|
||||
return jsonutils.loads(body.decode('utf-8'))
|
||||
|
@ -13,7 +13,7 @@
|
||||
# under the License.
|
||||
#
|
||||
|
||||
import json
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
from tempest import config
|
||||
|
||||
@ -337,9 +337,9 @@ class LoadbalancerClient(base_client.BaseLBaaSClient):
|
||||
response, body = self.get(request_uri)
|
||||
self.expected_success(200, response.status)
|
||||
if return_object_only:
|
||||
return json.loads(body.decode('utf-8'))['stats']
|
||||
return jsonutils.loads(body.decode('utf-8'))['stats']
|
||||
else:
|
||||
return json.loads(body.decode('utf-8'))
|
||||
return jsonutils.loads(body.decode('utf-8'))
|
||||
|
||||
def get_loadbalancer_status(self, lb_id, query_params=None,
|
||||
return_object_only=True):
|
||||
@ -387,6 +387,6 @@ class LoadbalancerClient(base_client.BaseLBaaSClient):
|
||||
response, body = self.get(request_uri)
|
||||
self.expected_success(200, response.status)
|
||||
if return_object_only:
|
||||
return json.loads(body.decode('utf-8'))['statuses']
|
||||
return jsonutils.loads(body.decode('utf-8'))['statuses']
|
||||
else:
|
||||
return json.loads(body.decode('utf-8'))
|
||||
return jsonutils.loads(body.decode('utf-8'))
|
||||
|
@ -12,9 +12,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
from tempest import config
|
||||
|
||||
from octavia_tempest_plugin.services.load_balancer.v2 import base_client
|
||||
@ -269,7 +268,7 @@ class MemberClient(base_client.BaseLBaaSClient):
|
||||
obj_dict = {self.list_root_tag: members_list}
|
||||
request_uri = self.uri.format(parent=pool_id)
|
||||
|
||||
response, body = self.put(request_uri, json.dumps(obj_dict))
|
||||
response, body = self.put(request_uri, jsonutils.dumps(obj_dict))
|
||||
self.expected_success(202, response.status)
|
||||
return
|
||||
|
||||
|
@ -9,6 +9,7 @@ pbr!=2.1.0,>=2.0.0 # Apache-2.0
|
||||
octavia-lib>=1.0.0 # Apache-2.0
|
||||
oslo.config>=5.2.0 # Apache-2.0
|
||||
oslo.log>=3.36.0 # Apache-2.0
|
||||
oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0
|
||||
oslo.utils>=3.33.0 # Apache-2.0
|
||||
oslotest>=3.2.0 # Apache-2.0
|
||||
python-barbicanclient>=4.5.2 # Apache-2.0
|
||||
|
Loading…
Reference in New Issue
Block a user