diff --git a/ironic_python_agent/inspector.py b/ironic_python_agent/inspector.py index bcd544892..97d827744 100644 --- a/ironic_python_agent/inspector.py +++ b/ironic_python_agent/inspector.py @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import json import os import time @@ -21,6 +20,7 @@ import netaddr from oslo_concurrency import processutils from oslo_config import cfg from oslo_log import log as logging +from oslo_serialization import jsonutils from oslo_utils import excutils from oslo_utils import units import requests @@ -363,7 +363,7 @@ def collect_extra_hardware(data, failures): return try: - data['data'] = json.loads(out) + data['data'] = jsonutils.loads(out) except ValueError as exc: msg = 'JSON returned from hardware-detect cannot be decoded: %s' failures.add(msg, exc) diff --git a/ironic_python_agent/ironic_api_client.py b/ironic_python_agent/ironic_api_client.py index 6d48e5514..1fd8caf12 100644 --- a/ironic_python_agent/ironic_api_client.py +++ b/ironic_python_agent/ironic_api_client.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import json from oslo_log import log +from oslo_serialization import jsonutils from oslo_service import loopingcall import requests @@ -72,7 +72,7 @@ class APIClient(object): raise errors.HeartbeatError(str(e)) if response.status_code == requests.codes.CONFLICT: - data = json.loads(response.content) + data = jsonutils.loads(response.content) raise errors.HeartbeatConflictError(data.get('faultstring')) elif response.status_code != requests.codes.ACCEPTED: msg = 'Invalid status code: {}'.format(response.status_code) @@ -118,7 +118,7 @@ class APIClient(object): return False try: - content = json.loads(response.content) + content = jsonutils.loads(response.content) except Exception as e: LOG.warning('Error decoding response: %s', e) return False diff --git a/ironic_python_agent/tests/unit/test_agent.py b/ironic_python_agent/tests/unit/test_agent.py index 7c35ec682..a0a0690d1 100644 --- a/ironic_python_agent/tests/unit/test_agent.py +++ b/ironic_python_agent/tests/unit/test_agent.py @@ -12,13 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -import json import socket import time import mock from oslo_concurrency import processutils from oslo_config import cfg +from oslo_serialization import jsonutils from oslotest import base as test_base import pkg_resources from stevedore import extension @@ -158,7 +158,8 @@ class TestBaseAgent(test_base.BaseTestCase): # object. a_encoded = self.encoder.encode(a) b_encoded = self.encoder.encode(b) - self.assertEqual(json.loads(a_encoded), json.loads(b_encoded)) + self.assertEqual(jsonutils.loads(a_encoded), + jsonutils.loads(b_encoded)) def test_get_status(self): started_at = time.time() diff --git a/ironic_python_agent/tests/unit/test_ironic_api_client.py b/ironic_python_agent/tests/unit/test_ironic_api_client.py index 3c345a931..3fe1807c0 100644 --- a/ironic_python_agent/tests/unit/test_ironic_api_client.py +++ b/ironic_python_agent/tests/unit/test_ironic_api_client.py @@ -12,9 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import json - import mock +from oslo_serialization import jsonutils from oslo_service import loopingcall from oslotest import base as test_base @@ -28,7 +27,7 @@ API_URL = 'http://agent-api.ironic.example.org/' class FakeResponse(object): def __init__(self, content=None, status_code=200, headers=None): content = content or {} - self.content = json.dumps(content) + self.content = jsonutils.dumps(content) self.status_code = status_code self.headers = headers or {} diff --git a/requirements.txt b/requirements.txt index 60f0a09b5..918400572 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,6 +9,7 @@ netifaces>=0.10.4 # MIT oslo.config!=3.18.0,>=3.14.0 # Apache-2.0 oslo.concurrency>=3.8.0 # Apache-2.0 oslo.log>=3.11.0 # Apache-2.0 +oslo.serialization>=1.10.0 # Apache-2.0 oslo.service>=1.10.0 # Apache-2.0 oslo.utils>=3.18.0 # Apache-2.0 pecan!=1.0.2,!=1.0.3,!=1.0.4,!=1.2,>=1.0.0 # BSD