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.
|
# limitations under the License.
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from glanceclient.common import exceptions as glance_exception
|
from glanceclient.common import exceptions as glance_exception
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
import six
|
import six
|
||||||
|
|
||||||
|
@ -373,7 +373,7 @@ def get_os_image(context, ec2_image_id):
|
||||||
def deserialize_os_image_properties(os_image):
|
def deserialize_os_image_properties(os_image):
|
||||||
def prepare_property(property_name):
|
def prepare_property(property_name):
|
||||||
if property_name in os_image_dict:
|
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[property_name])
|
||||||
|
|
||||||
os_image_dict = dict(os_image)
|
os_image_dict = dict(os_image)
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import binascii
|
import binascii
|
||||||
import json
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import tarfile
|
import tarfile
|
||||||
|
@ -33,6 +32,7 @@ from lxml import etree
|
||||||
from oslo_concurrency import processutils
|
from oslo_concurrency import processutils
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from ec2api.api import common
|
from ec2api.api import common
|
||||||
|
@ -258,7 +258,7 @@ def register_image(context, name=None, image_location=None,
|
||||||
except cinder_exception.NotFound:
|
except cinder_exception.NotFound:
|
||||||
pass
|
pass
|
||||||
metadata['bdm_v2'] = 'True'
|
metadata['bdm_v2'] = 'True'
|
||||||
metadata['block_device_mapping'] = json.dumps(mappings)
|
metadata['block_device_mapping'] = jsonutils.dumps(mappings)
|
||||||
if architecture is not None:
|
if architecture is not None:
|
||||||
metadata['architecture'] = architecture
|
metadata['architecture'] = architecture
|
||||||
if kernel_id:
|
if kernel_id:
|
||||||
|
|
|
@ -16,13 +16,13 @@
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
import functools
|
import functools
|
||||||
import json
|
|
||||||
import random
|
import random
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_db import exception as db_exception
|
from oslo_db import exception as db_exception
|
||||||
from oslo_db.sqlalchemy import session as db_session
|
from oslo_db.sqlalchemy import session as db_session
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
from sqlalchemy import and_
|
from sqlalchemy import and_
|
||||||
from sqlalchemy import or_
|
from sqlalchemy import or_
|
||||||
from sqlalchemy.sql import bindparam
|
from sqlalchemy.sql import bindparam
|
||||||
|
@ -318,7 +318,7 @@ def _pack_item_data(item_data):
|
||||||
return {
|
return {
|
||||||
"os_id": data.pop("os_id", None),
|
"os_id": data.pop("os_id", None),
|
||||||
"vpc_id": data.pop("vpc_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:
|
if item_ref is None:
|
||||||
return None
|
return None
|
||||||
data = item_ref.data
|
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["id"] = item_ref.id
|
||||||
data["os_id"] = item_ref.os_id
|
data["os_id"] = item_ref.os_id
|
||||||
data["vpc_id"] = item_ref.vpc_id
|
data["vpc_id"] = item_ref.vpc_id
|
||||||
|
|
|
@ -14,11 +14,11 @@
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
import copy
|
import copy
|
||||||
import json
|
|
||||||
import random
|
import random
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
|
|
||||||
from ec2api.api import ec2utils
|
from ec2api.api import ec2utils
|
||||||
from ec2api.tests.unit import tools
|
from ec2api.tests.unit import tools
|
||||||
|
@ -1581,7 +1581,7 @@ class OSImage(object):
|
||||||
for k in attrs})
|
for k in attrs})
|
||||||
for complex_attr in ('mappings', 'block_device_mapping'):
|
for complex_attr in ('mappings', 'block_device_mapping'):
|
||||||
if complex_attr in self._image_dict:
|
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])
|
self._image_dict[complex_attr])
|
||||||
for k in self._image_dict:
|
for k in self._image_dict:
|
||||||
setattr(self, k, self._image_dict[k])
|
setattr(self, k, self._image_dict[k])
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import json
|
|
||||||
import os
|
import os
|
||||||
import six
|
import six
|
||||||
import tempfile
|
import tempfile
|
||||||
|
@ -21,6 +20,7 @@ from cinderclient import exceptions as cinder_exception
|
||||||
import eventlet
|
import eventlet
|
||||||
import mock
|
import mock
|
||||||
from oslo_concurrency import processutils
|
from oslo_concurrency import processutils
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
|
|
||||||
from ec2api.api import image as image_api
|
from ec2api.api import image as image_api
|
||||||
from ec2api import exception
|
from ec2api import exception
|
||||||
|
@ -333,7 +333,7 @@ class ImageTestCase(base.ApiTestCase):
|
||||||
'device_name': '/dev/vdh',
|
'device_name': '/dev/vdh',
|
||||||
'source_type': 'snapshot',
|
'source_type': 'snapshot',
|
||||||
'snapshot_id': fakes.ID_OS_SNAPSHOT_2}],
|
'snapshot_id': fakes.ID_OS_SNAPSHOT_2}],
|
||||||
json.loads(bdm))
|
jsonutils.loads(bdm))
|
||||||
get_os_image.assert_has_calls(
|
get_os_image.assert_has_calls(
|
||||||
[mock.call(mock.ANY, fakes.ID_EC2_IMAGE_AKI_1),
|
[mock.call(mock.ANY, fakes.ID_EC2_IMAGE_AKI_1),
|
||||||
mock.call(mock.ANY, fakes.ID_EC2_IMAGE_ARI_1)])
|
mock.call(mock.ANY, fakes.ID_EC2_IMAGE_ARI_1)])
|
||||||
|
|
Loading…
Reference in New Issue