diff options
author | Takashi NATSUME <natsume.takashi@lab.ntt.co.jp> | 2018-07-31 11:59:54 +0900 |
---|---|---|
committer | Takashi NATSUME <natsume.takashi@lab.ntt.co.jp> | 2018-07-31 13:19:01 +0900 |
commit | 1f75c7662d6759354210a63ab7cdc06ba4237a2d (patch) | |
tree | 4c0d19cc2295ca3c2e89236d01d65e2b9643a1de | |
parent | 5680fea3980e58a15e3dd24d7353837e57972e2f (diff) | |
download | python-novaclient-1f75c7662d6759354210a63ab7cdc06ba4237a2d.tar.gz |
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
-rw-r--r-- | novaclient/tests/functional/v2/legacy/test_extended_attributes.py | 4 | ||||
-rw-r--r-- | novaclient/tests/functional/v2/test_extended_attributes.py | 4 | ||||
-rw-r--r-- | novaclient/utils.py | 3 | ||||
-rw-r--r-- | novaclient/v2/assisted_volume_snapshots.py | 5 |
4 files changed, 8 insertions, 8 deletions
diff --git a/novaclient/tests/functional/v2/legacy/test_extended_attributes.py b/novaclient/tests/functional/v2/legacy/test_extended_attributes.py index 06f4008e..6affb742 100644 --- a/novaclient/tests/functional/v2/legacy/test_extended_attributes.py +++ b/novaclient/tests/functional/v2/legacy/test_extended_attributes.py @@ -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]) diff --git a/novaclient/tests/functional/v2/test_extended_attributes.py b/novaclient/tests/functional/v2/test_extended_attributes.py index 6fddcc95..b585a34b 100644 --- a/novaclient/tests/functional/v2/test_extended_attributes.py +++ b/novaclient/tests/functional/v2/test_extended_attributes.py @@ -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]) diff --git a/novaclient/utils.py b/novaclient/utils.py index 8869f696..6f3cf640 100644 --- a/novaclient/utils.py +++ b/novaclient/utils.py @@ -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 diff --git a/novaclient/v2/assisted_volume_snapshots.py b/novaclient/v2/assisted_volume_snapshots.py index 79807897..9e0675a9 100644 --- a/novaclient/v2/assisted_volume_snapshots.py +++ b/novaclient/v2/assisted_volume_snapshots.py @@ -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))) |