From 7358119cd2d7c39c66a5600d2f9ac3ae6062ea5e Mon Sep 17 00:00:00 2001 From: zhulingjie Date: Tue, 26 Feb 2019 12:09:59 +0800 Subject: [PATCH] Update json module to jsonutils oslo project provide jsonutils, and zun use it in many place[1], this PS to update the remained json module to oslo jsonutils for consistency. [1]: https://github.com/openstack/zun/search?utf8=%E2%9C%93&q=jsonutils&type= Change-Id: Icc2d8345dd1b47a508f0c6f65671c76a7af7bd0f --- zun/common/utils.py | 4 ++-- .../3e80bbfd8da7_convert_type_of_command_from_string_to_.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/zun/common/utils.py b/zun/common/utils.py index 22134330e..083e58c44 100644 --- a/zun/common/utils.py +++ b/zun/common/utils.py @@ -21,13 +21,13 @@ import binascii import eventlet import functools import inspect -import json import mimetypes from oslo_concurrency import lockutils from oslo_concurrency import processutils from oslo_context import context as common_context from oslo_log import log as logging +from oslo_serialization import jsonutils from oslo_utils import excutils from oslo_utils import strutils import pecan @@ -369,7 +369,7 @@ def check_capsule_template(tpl): tpl_json = tpl if isinstance(tpl, six.string_types): try: - tpl_json = json.loads(tpl) + tpl_json = jsonutils.loads(tpl) except Exception as e: raise exception.FailedParseStringToJson(e) diff --git a/zun/db/sqlalchemy/alembic/versions/3e80bbfd8da7_convert_type_of_command_from_string_to_.py b/zun/db/sqlalchemy/alembic/versions/3e80bbfd8da7_convert_type_of_command_from_string_to_.py index 073dbfc6e..4ee5cdcc5 100644 --- a/zun/db/sqlalchemy/alembic/versions/3e80bbfd8da7_convert_type_of_command_from_string_to_.py +++ b/zun/db/sqlalchemy/alembic/versions/3e80bbfd8da7_convert_type_of_command_from_string_to_.py @@ -19,12 +19,13 @@ Create Date: 2018-06-20 11:21:38.077673 """ -import json import shlex from alembic import op import sqlalchemy as sa +from oslo_serialization import jsonutils + # revision identifiers, used by Alembic. revision = '3e80bbfd8da7' @@ -47,7 +48,7 @@ def upgrade(): for row in session.query(TABLE_MODEL): if row[1]: command = shlex.split(row[1]) - command = json.dumps(command) + command = jsonutils.dumps(command) session.execute( TABLE_MODEL.update().values( command=command).where(