Python 3 Compatible JSON

In order to be really python3 compatible, the json lib was replaced
with oslo.serialization(1.10 or newer) module jsontuils since it's
the recommended migration to python3 guide.

https://wiki.openstack.org/wiki/Python3#Serialization:_base64.2C_JSON.2C_etc.

Change-Id: I2d8b62e642aba4ccd1b70be7e9b3784a95a6743d
Closes-Bug: #1629068
This commit is contained in:
Luong Anh Tuan
2016-11-15 14:36:46 +07:00
committed by Tuan Luong-Anh
parent f330dac837
commit ab41106cf6
5 changed files with 11 additions and 10 deletions

@ -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