Update json module to jsonutils
oslo project provide jsonutils, and karbor use it in many place[1], this PS to update the remained json module to oslo jsonutils for consistency. [1]: https://github.com/openstack/karbor/search?q=jsonutils&unscoped_q=jsonutils Change-Id: I8a191a0a668a05eb1a63bb6cf45eb2624a7f848a
This commit is contained in:
parent
d862d4e6d8
commit
98cdd8207e
|
@ -20,7 +20,8 @@ from horizon import exceptions
|
|||
from horizon import forms as horizon_forms
|
||||
from horizon import messages
|
||||
|
||||
import json
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
from karbor_dashboard.api import karbor as karborclient
|
||||
|
||||
EMPTY_VALUES = (None, '', u'', [], (), {})
|
||||
|
@ -85,7 +86,7 @@ class RestoreCheckpointForm(horizon_forms.SelfHandlingForm):
|
|||
|
||||
provider_id = str(kwargs["initial"]["provider_id"])
|
||||
provider = karborclient.provider_get(request, provider_id)
|
||||
self.fields['provider'].initial = json.dumps(provider._info)
|
||||
self.fields['provider'].initial = jsonutils.dumps(provider._info)
|
||||
|
||||
@sensitive_variables('restore_target_password')
|
||||
def handle(self, request, data):
|
||||
|
@ -114,7 +115,7 @@ class RestoreCheckpointForm(horizon_forms.SelfHandlingForm):
|
|||
return False
|
||||
|
||||
try:
|
||||
data_parameters = json.loads(data["parameters"])
|
||||
data_parameters = jsonutils.loads(data["parameters"])
|
||||
restore_auth = {
|
||||
"type": "password",
|
||||
"username": target_username,
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
import collections
|
||||
from collections import namedtuple
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
import json
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
FILTER_LIST = ['provider_filter', 'plan_filter', 'date_filter']
|
||||
|
||||
|
@ -46,7 +46,7 @@ PackedGraph = namedtuple('PackedGraph', ['nodes', 'adjacency'])
|
|||
|
||||
|
||||
def deserialize_resource_graph(serialized_resource_graph):
|
||||
deserialized_graph = json.loads(serialized_resource_graph)
|
||||
deserialized_graph = jsonutils.loads(serialized_resource_graph)
|
||||
packed_resource_graph = PackedGraph(nodes=deserialized_graph[0],
|
||||
adjacency=deserialized_graph[1])
|
||||
for sid, node in packed_resource_graph.nodes.items():
|
||||
|
|
|
@ -19,7 +19,8 @@ from horizon import exceptions
|
|||
from horizon import forms as horizon_forms
|
||||
from horizon import messages
|
||||
|
||||
import json
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
from karbor_dashboard.api import karbor as karborclient
|
||||
|
||||
STATUS_CHOICE = [("suspended", "suspended"),
|
||||
|
@ -50,7 +51,7 @@ class CreateProtectionPlanForm(horizon_forms.SelfHandlingForm):
|
|||
providers = karborclient.provider_list(request)
|
||||
|
||||
self.fields['providers'].initial = \
|
||||
json.dumps([f._info for f in providers])
|
||||
jsonutils.dumps([f._info for f in providers])
|
||||
|
||||
if providers:
|
||||
result = [(e.id, e.name) for e in providers]
|
||||
|
@ -59,9 +60,9 @@ class CreateProtectionPlanForm(horizon_forms.SelfHandlingForm):
|
|||
|
||||
def handle(self, request, data):
|
||||
try:
|
||||
resources = json.loads(data["resources"])
|
||||
resources = jsonutils.loads(data["resources"])
|
||||
types = {resource["type"] for resource in resources}
|
||||
parameters = json.loads(data["parameters"])
|
||||
parameters = jsonutils.loads(data["parameters"])
|
||||
parameters = {k: v for k, v in parameters.items()
|
||||
if k.split("#")[0] in types}
|
||||
new_plan = karborclient.plan_create(
|
||||
|
@ -112,7 +113,7 @@ class UpdateProtectionPlanForm(horizon_forms.SelfHandlingForm):
|
|||
if name:
|
||||
data_.update({"name": name})
|
||||
|
||||
resources = json.loads(data["resources"])
|
||||
resources = jsonutils.loads(data["resources"])
|
||||
if resources:
|
||||
resources_ = []
|
||||
for resource in resources:
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.core.urlresolvers import reverse_lazy
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
@ -28,6 +26,7 @@ from karbor_dashboard.api import karbor as karborclient
|
|||
from karbor_dashboard.protectionplans import forms
|
||||
from karbor_dashboard.protectionplans import tables
|
||||
from karborclient.v1 import protectables
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
|
||||
|
@ -212,8 +211,8 @@ class UpdateView(horizon_forms.ModalFormView):
|
|||
provider = self.get_provider_object(plan.provider_id)
|
||||
initial.update({'plan_id': self.kwargs['plan_id'],
|
||||
'name': getattr(plan, 'name', ''),
|
||||
'plan': json.dumps(plan._info),
|
||||
'provider': json.dumps(provider._info)})
|
||||
'plan': jsonutils.dumps(plan._info),
|
||||
'provider': jsonutils.dumps(provider._info)})
|
||||
return initial
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue