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:
@@ -20,7 +20,8 @@ from horizon import exceptions
|
|||||||
from horizon import forms as horizon_forms
|
from horizon import forms as horizon_forms
|
||||||
from horizon import messages
|
from horizon import messages
|
||||||
|
|
||||||
import json
|
from oslo_serialization import jsonutils
|
||||||
|
|
||||||
from karbor_dashboard.api import karbor as karborclient
|
from karbor_dashboard.api import karbor as karborclient
|
||||||
|
|
||||||
EMPTY_VALUES = (None, '', u'', [], (), {})
|
EMPTY_VALUES = (None, '', u'', [], (), {})
|
||||||
@@ -85,7 +86,7 @@ class RestoreCheckpointForm(horizon_forms.SelfHandlingForm):
|
|||||||
|
|
||||||
provider_id = str(kwargs["initial"]["provider_id"])
|
provider_id = str(kwargs["initial"]["provider_id"])
|
||||||
provider = karborclient.provider_get(request, 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')
|
@sensitive_variables('restore_target_password')
|
||||||
def handle(self, request, data):
|
def handle(self, request, data):
|
||||||
@@ -114,7 +115,7 @@ class RestoreCheckpointForm(horizon_forms.SelfHandlingForm):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data_parameters = json.loads(data["parameters"])
|
data_parameters = jsonutils.loads(data["parameters"])
|
||||||
restore_auth = {
|
restore_auth = {
|
||||||
"type": "password",
|
"type": "password",
|
||||||
"username": target_username,
|
"username": target_username,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
import collections
|
import collections
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
import json
|
from oslo_serialization import jsonutils
|
||||||
|
|
||||||
FILTER_LIST = ['provider_filter', 'plan_filter', 'date_filter']
|
FILTER_LIST = ['provider_filter', 'plan_filter', 'date_filter']
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ PackedGraph = namedtuple('PackedGraph', ['nodes', 'adjacency'])
|
|||||||
|
|
||||||
|
|
||||||
def deserialize_resource_graph(serialized_resource_graph):
|
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],
|
packed_resource_graph = PackedGraph(nodes=deserialized_graph[0],
|
||||||
adjacency=deserialized_graph[1])
|
adjacency=deserialized_graph[1])
|
||||||
for sid, node in packed_resource_graph.nodes.items():
|
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 forms as horizon_forms
|
||||||
from horizon import messages
|
from horizon import messages
|
||||||
|
|
||||||
import json
|
from oslo_serialization import jsonutils
|
||||||
|
|
||||||
from karbor_dashboard.api import karbor as karborclient
|
from karbor_dashboard.api import karbor as karborclient
|
||||||
|
|
||||||
STATUS_CHOICE = [("suspended", "suspended"),
|
STATUS_CHOICE = [("suspended", "suspended"),
|
||||||
@@ -50,7 +51,7 @@ class CreateProtectionPlanForm(horizon_forms.SelfHandlingForm):
|
|||||||
providers = karborclient.provider_list(request)
|
providers = karborclient.provider_list(request)
|
||||||
|
|
||||||
self.fields['providers'].initial = \
|
self.fields['providers'].initial = \
|
||||||
json.dumps([f._info for f in providers])
|
jsonutils.dumps([f._info for f in providers])
|
||||||
|
|
||||||
if providers:
|
if providers:
|
||||||
result = [(e.id, e.name) for e in providers]
|
result = [(e.id, e.name) for e in providers]
|
||||||
@@ -59,9 +60,9 @@ class CreateProtectionPlanForm(horizon_forms.SelfHandlingForm):
|
|||||||
|
|
||||||
def handle(self, request, data):
|
def handle(self, request, data):
|
||||||
try:
|
try:
|
||||||
resources = json.loads(data["resources"])
|
resources = jsonutils.loads(data["resources"])
|
||||||
types = {resource["type"] for resource in 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()
|
parameters = {k: v for k, v in parameters.items()
|
||||||
if k.split("#")[0] in types}
|
if k.split("#")[0] in types}
|
||||||
new_plan = karborclient.plan_create(
|
new_plan = karborclient.plan_create(
|
||||||
@@ -112,7 +113,7 @@ class UpdateProtectionPlanForm(horizon_forms.SelfHandlingForm):
|
|||||||
if name:
|
if name:
|
||||||
data_.update({"name": name})
|
data_.update({"name": name})
|
||||||
|
|
||||||
resources = json.loads(data["resources"])
|
resources = jsonutils.loads(data["resources"])
|
||||||
if resources:
|
if resources:
|
||||||
resources_ = []
|
resources_ = []
|
||||||
for resource in resources:
|
for resource in resources:
|
||||||
|
|||||||
@@ -12,8 +12,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import json
|
|
||||||
|
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.core.urlresolvers import reverse_lazy
|
from django.core.urlresolvers import reverse_lazy
|
||||||
from django.utils.translation import ugettext_lazy as _
|
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 forms
|
||||||
from karbor_dashboard.protectionplans import tables
|
from karbor_dashboard.protectionplans import tables
|
||||||
from karborclient.v1 import protectables
|
from karborclient.v1 import protectables
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
|
|
||||||
|
|
||||||
@@ -212,8 +211,8 @@ class UpdateView(horizon_forms.ModalFormView):
|
|||||||
provider = self.get_provider_object(plan.provider_id)
|
provider = self.get_provider_object(plan.provider_id)
|
||||||
initial.update({'plan_id': self.kwargs['plan_id'],
|
initial.update({'plan_id': self.kwargs['plan_id'],
|
||||||
'name': getattr(plan, 'name', ''),
|
'name': getattr(plan, 'name', ''),
|
||||||
'plan': json.dumps(plan._info),
|
'plan': jsonutils.dumps(plan._info),
|
||||||
'provider': json.dumps(provider._info)})
|
'provider': jsonutils.dumps(provider._info)})
|
||||||
return initial
|
return initial
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user