Use jsonutils of oslo.serialization

Both standard json library and jsonutils of oslo.serialization are used.
Replace standard json library with jsonutils for consistency.

Change-Id: Id6cbb4d78817ff4993b73538935cc4cc61b64a72
This commit is contained in:
Takashi NATSUME 2018-07-31 11:59:54 +09:00
parent 5680fea398
commit 1f75c7662d
4 changed files with 8 additions and 8 deletions

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import json
from oslo_serialization import jsonutils
from novaclient.tests.functional import base
@ -50,4 +50,4 @@ class TestExtAttrNovaClient(base.ClientTestBase):
volume_attr = self._get_value_from_the_table(
table, 'os-extended-volumes:volumes_attached')
# Check that 'id' exists as a key of volume_attr dict
self.assertIn('id', json.loads(volume_attr)[0])
self.assertIn('id', jsonutils.loads(volume_attr)[0])

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import json
from oslo_serialization import jsonutils
from novaclient.tests.functional.v2.legacy import test_extended_attributes
@ -41,4 +41,4 @@ class TestExtAttrNovaClientV23(test_extended_attributes.TestExtAttrNovaClient):
table, 'os-extended-volumes:volumes_attached')
# Check that 'delete_on_termination' exists as a key
# of volume_attr dict
self.assertIn('delete_on_termination', json.loads(volume_attr)[0])
self.assertIn('delete_on_termination', jsonutils.loads(volume_attr)[0])

View File

@ -12,7 +12,6 @@
# under the License.
import contextlib
import json
import os
import re
import textwrap
@ -199,7 +198,7 @@ def flatten_dict(data):
for key, value in data.items():
if isinstance(value, six.string_types):
try:
data[key] = json.loads(value)
data[key] = jsonutils.loads(value)
except ValueError:
pass

View File

@ -16,7 +16,7 @@
Assisted volume snapshots - to be used by Cinder and not end users.
"""
import json
from oslo_serialization import jsonutils
from novaclient import base
@ -51,4 +51,5 @@ class AssistedSnapshotManager(base.Manager):
:returns: An instance of novaclient.base.TupleWithMeta
"""
return self._delete("/os-assisted-volume-snapshots/%s?delete_info=%s" %
(base.getid(snapshot), json.dumps(delete_info)))
(base.getid(snapshot),
jsonutils.dumps(delete_info)))