From 1f35b8f25cb328ede6aea7933ecd33a1cd713ba8 Mon Sep 17 00:00:00 2001
From: "cao.yuan" <cao.yuan@99cloud.net>
Date: Mon, 25 Feb 2019 00:55:22 +0800
Subject: [PATCH] Update json module to jsonutils

oslo project provide jsonutils, and neutronclient use it in many place[1],
this PS to update the remained json module to oslo jsonutils for
consistency.

[1]: https://github.com/openstack/python-neutronclient/search?utf8=%E2%9C%93&q=jsonutils&type=

Change-Id: Ic4639628c8910b88a14b0fe8f37638bb4f9474be
---
 neutronclient/client.py                | 11 ++++-------
 neutronclient/tests/unit/test_cli20.py |  8 ++++----
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/neutronclient/client.py b/neutronclient/client.py
index 2482eb434..c5f467668 100644
--- a/neutronclient/client.py
+++ b/neutronclient/client.py
@@ -14,16 +14,13 @@
 #    under the License.
 #
 
-try:
-    import json
-except ImportError:
-    import simplejson as json
 import logging
 import os
 
 import debtcollector.renames
 from keystoneauth1 import access
 from keystoneauth1 import adapter
+from oslo_serialization import jsonutils
 from oslo_utils import importutils
 import requests
 
@@ -239,14 +236,14 @@ class HTTPClient(object):
 
         token_url = self.auth_url + "/tokens"
         resp, resp_body = self._cs_request(token_url, "POST",
-                                           body=json.dumps(body),
+                                           body=jsonutils.dumps(body),
                                            content_type="application/json",
                                            allow_redirects=True)
         if resp.status_code != 200:
             raise exceptions.Unauthorized(message=resp_body)
         if resp_body:
             try:
-                resp_body = json.loads(resp_body)
+                resp_body = jsonutils.loads(resp_body)
             except ValueError:
                 pass
         else:
@@ -282,7 +279,7 @@ class HTTPClient(object):
             self.authenticate()
             return self.endpoint_url
 
-        body = json.loads(body)
+        body = jsonutils.loads(body)
         for endpoint in body.get('endpoints', []):
             if (endpoint['type'] == 'network' and
                     endpoint.get('region') == self.region_name):
diff --git a/neutronclient/tests/unit/test_cli20.py b/neutronclient/tests/unit/test_cli20.py
index cfba9fafd..3a8bb4719 100644
--- a/neutronclient/tests/unit/test_cli20.py
+++ b/neutronclient/tests/unit/test_cli20.py
@@ -16,10 +16,10 @@
 
 import contextlib
 import itertools
-import json
 import sys
 
 import mock
+from oslo_serialization import jsonutils
 from oslo_utils import encodeutils
 from oslotest import base
 import requests
@@ -1153,7 +1153,7 @@ class CLITestV20OutputFormatter(CLITestV20Base):
 
     def test_create_resource_json(self):
         self._test_create_resource_with_formatter('json')
-        data = json.loads(self.fake_stdout.make_string())
+        data = jsonutils.loads(self.fake_stdout.make_string())
         self.assertEqual('myname', data['name'])
         self.assertEqual('myid', data['id'])
 
@@ -1178,7 +1178,7 @@ class CLITestV20OutputFormatter(CLITestV20Base):
 
     def test_show_resource_json(self):
         self._test_show_resource_with_formatter('json')
-        data = json.loads(''.join(self.fake_stdout.content))
+        data = jsonutils.loads(''.join(self.fake_stdout.content))
         self.assertEqual('myname', data['name'])
         self.assertEqual('myid', data['id'])
 
@@ -1206,7 +1206,7 @@ class CLITestV20OutputFormatter(CLITestV20Base):
 
     def test_list_resources_json(self):
         self._test_list_resources_with_formatter('json')
-        data = json.loads(''.join(self.fake_stdout.content))
+        data = jsonutils.loads(''.join(self.fake_stdout.content))
         self.assertEqual(['myid1', 'myid2'], [d['id'] for d in data])
 
     def test_list_resources_yaml(self):