Update json module to jsonutils
oslo project provide jsonutils, and ec2api use it in many place[1], this PS to update the remained json module to oslo jsonutils for consistency. [1]: https://github.com/openstack/ec2-api/search?q=jsonutils&unscoped_q=jsonutils Change-Id: I46e7cfe55bd5cfbca90177bc4a970c726872bab4
This commit is contained in:
parent
f90d3b8532
commit
c27a8c4eae
|
@ -13,13 +13,13 @@
|
|||
# limitations under the License.
|
||||
|
||||
import datetime
|
||||
import json
|
||||
import re
|
||||
|
||||
from glanceclient.common import exceptions as glance_exception
|
||||
from lxml import etree
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
|
||||
|
@ -373,7 +373,7 @@ def get_os_image(context, ec2_image_id):
|
|||
def deserialize_os_image_properties(os_image):
|
||||
def prepare_property(property_name):
|
||||
if property_name in os_image_dict:
|
||||
os_image_dict[property_name] = json.loads(
|
||||
os_image_dict[property_name] = jsonutils.loads(
|
||||
os_image_dict[property_name])
|
||||
|
||||
os_image_dict = dict(os_image)
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
# limitations under the License.
|
||||
|
||||
import binascii
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import tarfile
|
||||
|
@ -33,6 +32,7 @@ from lxml import etree
|
|||
from oslo_concurrency import processutils
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
import six
|
||||
|
||||
from ec2api.api import common
|
||||
|
@ -258,7 +258,7 @@ def register_image(context, name=None, image_location=None,
|
|||
except cinder_exception.NotFound:
|
||||
pass
|
||||
metadata['bdm_v2'] = 'True'
|
||||
metadata['block_device_mapping'] = json.dumps(mappings)
|
||||
metadata['block_device_mapping'] = jsonutils.dumps(mappings)
|
||||
if architecture is not None:
|
||||
metadata['architecture'] = architecture
|
||||
if kernel_id:
|
||||
|
|
|
@ -16,13 +16,13 @@
|
|||
|
||||
import copy
|
||||
import functools
|
||||
import json
|
||||
import random
|
||||
import sys
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_db import exception as db_exception
|
||||
from oslo_db.sqlalchemy import session as db_session
|
||||
from oslo_serialization import jsonutils
|
||||
from sqlalchemy import and_
|
||||
from sqlalchemy import or_
|
||||
from sqlalchemy.sql import bindparam
|
||||
|
@ -318,7 +318,7 @@ def _pack_item_data(item_data):
|
|||
return {
|
||||
"os_id": data.pop("os_id", None),
|
||||
"vpc_id": data.pop("vpc_id", None),
|
||||
"data": json.dumps(data),
|
||||
"data": jsonutils.dumps(data),
|
||||
}
|
||||
|
||||
|
||||
|
@ -326,7 +326,7 @@ def _unpack_item_data(item_ref):
|
|||
if item_ref is None:
|
||||
return None
|
||||
data = item_ref.data
|
||||
data = json.loads(data) if data is not None else {}
|
||||
data = jsonutils.loads(data) if data is not None else {}
|
||||
data["id"] = item_ref.id
|
||||
data["os_id"] = item_ref.os_id
|
||||
data["vpc_id"] = item_ref.vpc_id
|
||||
|
|
|
@ -14,11 +14,11 @@
|
|||
|
||||
import base64
|
||||
import copy
|
||||
import json
|
||||
import random
|
||||
import uuid
|
||||
|
||||
from lxml import etree
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
from ec2api.api import ec2utils
|
||||
from ec2api.tests.unit import tools
|
||||
|
@ -1581,7 +1581,7 @@ class OSImage(object):
|
|||
for k in attrs})
|
||||
for complex_attr in ('mappings', 'block_device_mapping'):
|
||||
if complex_attr in self._image_dict:
|
||||
self._image_dict[complex_attr] = json.dumps(
|
||||
self._image_dict[complex_attr] = jsonutils.dumps(
|
||||
self._image_dict[complex_attr])
|
||||
for k in self._image_dict:
|
||||
setattr(self, k, self._image_dict[k])
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import json
|
||||
import os
|
||||
import six
|
||||
import tempfile
|
||||
|
@ -21,6 +20,7 @@ from cinderclient import exceptions as cinder_exception
|
|||
import eventlet
|
||||
import mock
|
||||
from oslo_concurrency import processutils
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
from ec2api.api import image as image_api
|
||||
from ec2api import exception
|
||||
|
@ -333,7 +333,7 @@ class ImageTestCase(base.ApiTestCase):
|
|||
'device_name': '/dev/vdh',
|
||||
'source_type': 'snapshot',
|
||||
'snapshot_id': fakes.ID_OS_SNAPSHOT_2}],
|
||||
json.loads(bdm))
|
||||
jsonutils.loads(bdm))
|
||||
get_os_image.assert_has_calls(
|
||||
[mock.call(mock.ANY, fakes.ID_EC2_IMAGE_AKI_1),
|
||||
mock.call(mock.ANY, fakes.ID_EC2_IMAGE_ARI_1)])
|
||||
|
|
Loading…
Reference in New Issue