Merge "Update json module to jsonutils"
This commit is contained in:
commit
036ec8746a
|
@ -25,14 +25,10 @@ OpenStack Client interface. Handles the REST calls and responses.
|
|||
# E0202: An attribute inherited from %s hide this method
|
||||
# pylint: disable=E0202
|
||||
|
||||
try:
|
||||
import simplejson as json
|
||||
except ImportError:
|
||||
import json
|
||||
|
||||
import time
|
||||
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import importutils
|
||||
import requests
|
||||
|
||||
|
@ -132,7 +128,7 @@ class HTTPClient(object):
|
|||
def serialize(self, kwargs):
|
||||
if kwargs.get('json') is not None:
|
||||
kwargs['headers']['Content-Type'] = 'application/json'
|
||||
kwargs['data'] = json.dumps(kwargs['json'])
|
||||
kwargs['data'] = jsonutils.dumps(kwargs['json'])
|
||||
try:
|
||||
del kwargs['json']
|
||||
except KeyError:
|
||||
|
|
|
@ -24,7 +24,7 @@ places where actual behavior differs from the spec.
|
|||
# W0102: Dangerous default value %s as argument
|
||||
# pylint: disable=W0102
|
||||
|
||||
import json
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
import requests
|
||||
import six
|
||||
|
@ -58,7 +58,7 @@ class TestResponse(requests.Response):
|
|||
# Fake the text attribute to streamline Response creation
|
||||
text = data.get('text', "")
|
||||
if isinstance(text, (dict, list)):
|
||||
self._content = json.dumps(text)
|
||||
self._content = jsonutils.dumps(text)
|
||||
default_headers = {
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
|
|
@ -12,13 +12,13 @@
|
|||
|
||||
from __future__ import print_function
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
import six
|
||||
import uuid
|
||||
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import encodeutils
|
||||
|
||||
import prettytable
|
||||
|
@ -138,7 +138,7 @@ def dict_prettyprint(val):
|
|||
:param val: dict.
|
||||
:return: formatted json string.
|
||||
"""
|
||||
return json.dumps(val, indent=2, sort_keys=True)
|
||||
return jsonutils.dumps(val, indent=2, sort_keys=True)
|
||||
|
||||
|
||||
def json_prettyprint(val):
|
||||
|
@ -147,7 +147,8 @@ def json_prettyprint(val):
|
|||
:param val: json string.
|
||||
:return: formatted json string.
|
||||
"""
|
||||
return val and json.dumps(json.loads(val), indent=2, sort_keys=True)
|
||||
return val and jsonutils.dumps(jsonutils.loads(val),
|
||||
indent=2, sort_keys=True)
|
||||
|
||||
|
||||
def find_resource(manager, name_or_id, *args, **kwargs):
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
|
||||
"""Data protection V1 checkpoint action implementations"""
|
||||
|
||||
import json
|
||||
from osc_lib.command import command
|
||||
from osc_lib import utils as osc_utils
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
from karborclient.common.apiclient import exceptions
|
||||
from karborclient.i18n import _
|
||||
|
@ -28,7 +28,7 @@ def format_checkpoint(checkpoint_info):
|
|||
checkpoint_info['protection_plan'] = "Name: %s\nId: %s" % (
|
||||
plan['name'], plan['id'])
|
||||
if 'resource_graph' in checkpoint_info:
|
||||
checkpoint_info['resource_graph'] = json.dumps(json.loads(
|
||||
checkpoint_info['resource_graph'] = jsonutils.dumps(jsonutils.loads(
|
||||
checkpoint_info['resource_graph']), indent=2, sort_keys=True)
|
||||
checkpoint_info.pop("links", None)
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
"""Data protection V1 plan action implementations"""
|
||||
|
||||
import json
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from osc_lib.command import command
|
||||
|
@ -28,7 +28,8 @@ def format_plan(plan_info):
|
|||
for key in ('resources', 'parameters'):
|
||||
if key not in plan_info:
|
||||
continue
|
||||
plan_info[key] = json.dumps(plan_info[key], indent=2, sort_keys=True)
|
||||
plan_info[key] = jsonutils.dumps(plan_info[key],
|
||||
indent=2, sort_keys=True)
|
||||
plan_info.pop("links", None)
|
||||
|
||||
|
||||
|
|
|
@ -13,10 +13,10 @@
|
|||
"""Data protection V1 protectables action implementations"""
|
||||
|
||||
import functools
|
||||
import json
|
||||
from osc_lib.command import command
|
||||
from osc_lib import utils as osc_utils
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
from karborclient.i18n import _
|
||||
from karborclient import utils
|
||||
|
@ -136,7 +136,8 @@ class ListProtectableInstances(command.Lister):
|
|||
column_headers = ['Id', 'Type', 'Name', 'Dependent resources',
|
||||
'Extra info']
|
||||
|
||||
json_dumps = functools.partial(json.dumps, indent=2, sort_keys=True)
|
||||
json_dumps = functools.partial(jsonutils.dumps,
|
||||
indent=2, sort_keys=True)
|
||||
formatters = {
|
||||
"Extra info": json_dumps,
|
||||
"Dependent resources": json_dumps,
|
||||
|
@ -186,7 +187,8 @@ class ShowProtectableInstance(command.ShowOne):
|
|||
parsed_args.protectable_id,
|
||||
search_opts=search_opts)
|
||||
|
||||
json_dumps = functools.partial(json.dumps, indent=2, sort_keys=True)
|
||||
json_dumps = functools.partial(jsonutils.dumps,
|
||||
indent=2, sort_keys=True)
|
||||
instance._info.pop("links", None)
|
||||
for key in ('extra_info', 'dependent_resources'):
|
||||
if key not in instance._info:
|
||||
|
|
|
@ -13,10 +13,10 @@
|
|||
"""Data protection V1 provider action implementations"""
|
||||
|
||||
import functools
|
||||
import json
|
||||
from osc_lib.command import command
|
||||
from osc_lib import utils as osc_utils
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
from karborclient.i18n import _
|
||||
|
||||
|
@ -96,7 +96,8 @@ class ShowProvider(command.ShowOne):
|
|||
client = self.app.client_manager.data_protection
|
||||
provider = osc_utils.find_resource(client.providers,
|
||||
parsed_args.provider)
|
||||
json_dumps = functools.partial(json.dumps, indent=2, sort_keys=True)
|
||||
json_dumps = functools.partial(jsonutils.dumps,
|
||||
indent=2, sort_keys=True)
|
||||
provider._info.pop("links", None)
|
||||
if 'extended_info_schema' in provider._info:
|
||||
provider._info['extended_info_schema'] = json_dumps(
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
"""Data protection V1 restore action implementations"""
|
||||
|
||||
import functools
|
||||
import json
|
||||
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from osc_lib.command import command
|
||||
|
@ -31,8 +31,8 @@ def format_restore(restore_info):
|
|||
'resources_reason'):
|
||||
if key not in restore_info:
|
||||
continue
|
||||
restore_info[key] = json.dumps(restore_info[key],
|
||||
indent=2, sort_keys=True)
|
||||
restore_info[key] = jsonutils.dumps(restore_info[key],
|
||||
indent=2, sort_keys=True)
|
||||
restore_info.pop("links", None)
|
||||
|
||||
|
||||
|
@ -98,7 +98,9 @@ class ListRestores(command.Lister):
|
|||
column_headers = ['Id', 'Project id', 'Provider id', 'Checkpoint id',
|
||||
'Restore target', 'Parameters', 'Status']
|
||||
|
||||
json_dumps = functools.partial(json.dumps, indent=2, sort_keys=True)
|
||||
json_dumps = functools.partial(jsonutils.dumps,
|
||||
indent=2,
|
||||
sort_keys=True)
|
||||
formatters = {
|
||||
"Parameters": json_dumps,
|
||||
}
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
"""Data protection V1 scheduled_operations action implementations"""
|
||||
|
||||
import functools
|
||||
import json
|
||||
import six
|
||||
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from osc_lib.command import command
|
||||
|
@ -30,8 +30,8 @@ def format_scheduledoperation(scheduledoperation_info):
|
|||
for key in ('operation_definition', ):
|
||||
if key not in scheduledoperation_info:
|
||||
continue
|
||||
scheduledoperation_info[key] = json.dumps(scheduledoperation_info[key],
|
||||
indent=2, sort_keys=True)
|
||||
scheduledoperation_info[key] = jsonutils.dumps(
|
||||
scheduledoperation_info[key], indent=2, sort_keys=True)
|
||||
scheduledoperation_info.pop("links", None)
|
||||
|
||||
|
||||
|
@ -118,7 +118,9 @@ class ListScheduledOperations(command.Lister):
|
|||
column_headers = ['Id', 'Name', 'Operation Type', 'Trigger Id',
|
||||
'Operation Definition']
|
||||
|
||||
json_dumps = functools.partial(json.dumps, indent=2, sort_keys=True)
|
||||
json_dumps = functools.partial(jsonutils.dumps,
|
||||
indent=2,
|
||||
sort_keys=True)
|
||||
formatters = {
|
||||
"Operation Definition": json_dumps,
|
||||
}
|
||||
|
|
|
@ -13,13 +13,13 @@
|
|||
"""Data protection V1 verification action implementations"""
|
||||
|
||||
import functools
|
||||
import json
|
||||
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from osc_lib.command import command
|
||||
from osc_lib import utils as osc_utils
|
||||
from oslo_log import log as logging
|
||||
|
||||
from karborclient.common.apiclient import exceptions
|
||||
from karborclient.i18n import _
|
||||
|
@ -31,8 +31,8 @@ def format_verification(verification_info):
|
|||
'resources_reason'):
|
||||
if key not in verification_info:
|
||||
continue
|
||||
verification_info[key] = json.dumps(verification_info[key],
|
||||
indent=2, sort_keys=True)
|
||||
verification_info[key] = jsonutils.dumps(verification_info[key],
|
||||
indent=2, sort_keys=True)
|
||||
verification_info.pop("links", None)
|
||||
|
||||
|
||||
|
@ -98,7 +98,9 @@ class ListVerifications(command.Lister):
|
|||
column_headers = ['Id', 'Project id', 'Provider id', 'Checkpoint id',
|
||||
'Parameters', 'Status']
|
||||
|
||||
json_dumps = functools.partial(json.dumps, indent=2, sort_keys=True)
|
||||
json_dumps = functools.partial(jsonutils.dumps,
|
||||
indent=2,
|
||||
sort_keys=True)
|
||||
formatters = {
|
||||
"Parameters": json_dumps,
|
||||
}
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
# limitations under the License.
|
||||
|
||||
import copy
|
||||
import json
|
||||
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
from karborclient.osc.v1 import checkpoints as osc_checkpoints
|
||||
from karborclient.tests.unit.osc.v1 import fakes
|
||||
|
@ -32,7 +33,7 @@ CHECKPOINT_INFO = {
|
|||
"type": "OS::Glance::Image",
|
||||
"name": "cirros-0.3.4-x86_64-uec"}]
|
||||
},
|
||||
"resource_graph": json.dumps(
|
||||
"resource_graph": jsonutils.dumps(
|
||||
"[{'0x0': ['OS::Glance::Image', "
|
||||
"'99777fdd-8a5b-45ab-ba2c-52420008103f', "
|
||||
"'cirros-0.3.4-x86_64-uec']}, [[['0x0']]]]"
|
||||
|
@ -52,7 +53,7 @@ CHECKPOINT_INFO_2 = {
|
|||
"type": "OS::Glance::Image",
|
||||
"name": "cirros-0.3.4-x86_64-uec"}]
|
||||
},
|
||||
"resource_graph": json.dumps(
|
||||
"resource_graph": jsonutils.dumps(
|
||||
"[{'0x0': ['OS::Glance::Image', "
|
||||
"'99777fdd-8a5b-45ab-ba2c-52420008103f', "
|
||||
"'cirros-0.3.4-x86_64-uec']}, [[['0x0']]]]"
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
# limitations under the License.
|
||||
|
||||
import copy
|
||||
import json
|
||||
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
from karborclient.osc.v1 import restores as osc_restores
|
||||
from karborclient.tests.unit.osc.v1 import fakes
|
||||
|
@ -69,7 +70,7 @@ class TestListRestores(TestRestores):
|
|||
"cf56bd3e-97a7-4078-b6d5-f36246333fd9",
|
||||
"dcb20606-ad71-40a3-80e4-ef0fafdad0c3",
|
||||
"",
|
||||
json.dumps({}),
|
||||
jsonutils.dumps({}),
|
||||
"success")]
|
||||
self.assertEqual(expected_data, list(data))
|
||||
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
# limitations under the License.
|
||||
|
||||
import copy
|
||||
import json
|
||||
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
from karborclient.osc.v1 import verifications as osc_verifications
|
||||
from karborclient.tests.unit.osc.v1 import fakes
|
||||
|
@ -67,7 +68,7 @@ class TestListVerifications(TestVerifications):
|
|||
"e486a2f49695423ca9c47e589b948108",
|
||||
"cf56bd3e-97a7-4078-b6d5-f36246333fd9",
|
||||
"dcb20606-ad71-40a3-80e4-ef0fafdad0c3",
|
||||
json.dumps({}),
|
||||
jsonutils.dumps({}),
|
||||
"success")]
|
||||
self.assertEqual(expected_data, list(data))
|
||||
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
# under the License.
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
|
||||
from datetime import datetime
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from karborclient.common.apiclient import exceptions
|
||||
|
@ -353,7 +353,7 @@ def do_restore_list(cs, args):
|
|||
sortby_index = None
|
||||
else:
|
||||
sortby_index = 0
|
||||
formatters = {"Parameters": lambda obj: json.dumps(
|
||||
formatters = {"Parameters": lambda obj: jsonutils.dumps(
|
||||
obj.parameters, indent=2, sort_keys=True)}
|
||||
utils.print_list(restores, key_list, exclude_unavailable=True,
|
||||
sortby_index=sortby_index, formatters=formatters)
|
||||
|
@ -486,7 +486,7 @@ def do_verification_list(cs, args):
|
|||
sortby_index = None
|
||||
else:
|
||||
sortby_index = 0
|
||||
formatters = {"Parameters": lambda obj: json.dumps(
|
||||
formatters = {"Parameters": lambda obj: jsonutils.dumps(
|
||||
obj.parameters, indent=2, sort_keys=True)}
|
||||
utils.print_list(verifications, key_list, exclude_unavailable=True,
|
||||
sortby_index=sortby_index, formatters=formatters)
|
||||
|
@ -614,7 +614,7 @@ def do_protectable_list_instances(cs, args):
|
|||
else:
|
||||
sortby_index = 0
|
||||
|
||||
formatters = {"Dependent resources": lambda obj: json.dumps(
|
||||
formatters = {"Dependent resources": lambda obj: jsonutils.dumps(
|
||||
obj.dependent_resources, indent=2, sort_keys=True)}
|
||||
utils.print_list(instances, key_list, exclude_unavailable=True,
|
||||
sortby_index=sortby_index, formatters=formatters)
|
||||
|
@ -994,7 +994,7 @@ def do_trigger_list(cs, args):
|
|||
else:
|
||||
sortby_index = 0
|
||||
|
||||
formatters = {"Properties": lambda obj: json.dumps(
|
||||
formatters = {"Properties": lambda obj: jsonutils.dumps(
|
||||
obj.properties, indent=2, sort_keys=True)}
|
||||
utils.print_list(triggers, key_list, exclude_unavailable=True,
|
||||
sortby_index=sortby_index, formatters=formatters)
|
||||
|
|
Loading…
Reference in New Issue