From 734d407332426c580c7bfe3749a25102c57c31bb Mon Sep 17 00:00:00 2001 From: Ruslan Kamaldinov Date: Sat, 13 Dec 2014 18:05:15 +0300 Subject: [PATCH] Replace anyjson with oslo.serialization Now, when we started to use oslo.serialization it is safe to replace all the usages of anyjson with jsonutils from oslo library. oslo.serialization uses anyjson under the hood, so there shouldn't be any performance changes. Change-Id: I8d6fbfbf88e657f5586c7361de849683c064d2e2 --- murano/common/engine.py | 4 ++-- murano/common/messaging/message.py | 4 ++-- murano/common/messaging/mqclient.py | 4 ++-- murano/db/sqla/types.py | 6 +++--- requirements.txt | 1 - 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/murano/common/engine.py b/murano/common/engine.py index 8c0448b4..39f79086 100644 --- a/murano/common/engine.py +++ b/murano/common/engine.py @@ -15,10 +15,10 @@ import uuid -import anyjson import eventlet.debug from oslo import messaging from oslo.messaging import target +from oslo.serialization import jsonutils from murano.common import config from murano.common.helpers import token_sanitizer @@ -48,7 +48,7 @@ class TaskProcessingEndpoint(object): def handle_task(context, task): s_task = token_sanitizer.TokenSanitizer().sanitize(task) LOG.info(_('Starting processing task: {task_desc}').format( - task_desc=anyjson.dumps(s_task))) + task_desc=jsonutils.dumps(s_task))) result = task['model'] try: diff --git a/murano/common/messaging/message.py b/murano/common/messaging/message.py index 724c0c9c..f26d38dc 100644 --- a/murano/common/messaging/message.py +++ b/murano/common/messaging/message.py @@ -13,8 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import anyjson import logging +from oslo.serialization import jsonutils log = logging.getLogger("murano-common.messaging") @@ -28,7 +28,7 @@ class Message(object): message_handle.properties.get('message_id') try: self.body = None if message_handle is None else \ - anyjson.loads(message_handle.body) + jsonutils.loads(message_handle.body) except ValueError as e: self.body = None log.exception(e) diff --git a/murano/common/messaging/mqclient.py b/murano/common/messaging/mqclient.py index ee6c5654..35473c84 100644 --- a/murano/common/messaging/mqclient.py +++ b/murano/common/messaging/mqclient.py @@ -13,12 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -import anyjson import logging import ssl as ssl_module from eventlet import patcher kombu = patcher.import_patched('kombu') +from oslo.serialization import jsonutils from subscription import Subscription @@ -95,7 +95,7 @@ class MqClient(object): producer.publish( exchange=str(exchange), routing_key=str(key), - body=anyjson.dumps(message.body), + body=jsonutils.dumps(message.body), message_id=str(message.id) ) diff --git a/murano/db/sqla/types.py b/murano/db/sqla/types.py index 65d2f71d..e4b96cf1 100644 --- a/murano/db/sqla/types.py +++ b/murano/db/sqla/types.py @@ -10,7 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. -import anyjson +from oslo.serialization import jsonutils import sqlalchemy as sa from sqlalchemy.dialects import mysql @@ -23,9 +23,9 @@ class JsonBlob(sa.TypeDecorator): impl = sa.Text def process_bind_param(self, value, dialect): - return anyjson.serialize(value) + return jsonutils.dumps(value) def process_result_value(self, value, dialect): if value is not None: - return anyjson.deserialize(value) + return jsonutils.loads(value) return None diff --git a/requirements.txt b/requirements.txt index 9576c8c2..8f421567 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,6 @@ pbr>=0.6,!=0.7,<1.0 Babel>=1.3 SQLAlchemy>=0.8.4,<=0.8.99,>=0.9.7,<=0.9.99 alembic>=0.6.4 -anyjson>=0.3.3 eventlet>=0.15.2 PasteDeploy>=1.5.0 Routes>=1.12.3,!=2.0