Update json module to jsonutils
oslo project provide jsonutils, and tacker use it in many place[1], this PS to update the remained json moudule to oslo jsonutils. [1]: https://github.com/openstack/tacker/blob/master/tacker/vnfm/infra_drivers/openstack/translate_template.py Change-Id: Ic1d2b55fe67d9093d3f2e6e009576b103ba587c3
This commit is contained in:
parent
9cfab81c2c
commit
59b0586d23
|
@ -21,9 +21,10 @@ Create Date: 2016-06-01 09:50:46.296206
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import json
|
|
||||||
import pickle
|
import pickle
|
||||||
|
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
|
|
||||||
from alembic import op
|
from alembic import op
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
@ -40,7 +41,8 @@ def _migrate_data(table, column_name):
|
||||||
|
|
||||||
for r in t.select().execute():
|
for r in t.select().execute():
|
||||||
stmt = t.update().where(t.c.id == r.id).values(
|
stmt = t.update().where(t.c.id == r.id).values(
|
||||||
{column_name: json.dumps(pickle.loads(getattr(r, column_name)))})
|
{column_name: jsonutils.dump_as_bytes(
|
||||||
|
pickle.loads(getattr(r, column_name)))})
|
||||||
op.execute(stmt)
|
op.execute(stmt)
|
||||||
|
|
||||||
op.alter_column(table,
|
op.alter_column(table,
|
||||||
|
|
|
@ -10,9 +10,10 @@
|
||||||
# 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
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
|
|
||||||
from sqlalchemy.types import String
|
from sqlalchemy.types import String
|
||||||
from sqlalchemy.types import Text
|
from sqlalchemy.types import Text
|
||||||
from sqlalchemy.types import TypeDecorator
|
from sqlalchemy.types import TypeDecorator
|
||||||
|
@ -39,9 +40,9 @@ class Json(TypeDecorator):
|
||||||
impl = Text
|
impl = Text
|
||||||
|
|
||||||
def process_bind_param(self, value, dialect):
|
def process_bind_param(self, value, dialect):
|
||||||
return json.dumps(value)
|
return jsonutils.dump_as_bytes(value)
|
||||||
|
|
||||||
def process_result_value(self, value, dialect):
|
def process_result_value(self, value, dialect):
|
||||||
if value is None:
|
if value is None:
|
||||||
return None
|
return None
|
||||||
return json.loads(value)
|
return jsonutils.loads(value)
|
||||||
|
|
|
@ -12,9 +12,8 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
import json
|
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
|
@ -95,7 +94,7 @@ class TestVNFMonitor(testtools.TestCase):
|
||||||
'id': MOCK_VNF_ID,
|
'id': MOCK_VNF_ID,
|
||||||
'mgmt_ip_address': '{"vdu1": "a.b.c.d"}',
|
'mgmt_ip_address': '{"vdu1": "a.b.c.d"}',
|
||||||
'attributes': {
|
'attributes': {
|
||||||
'monitoring_policy': json.dumps(
|
'monitoring_policy': jsonutils.dump_as_bytes(
|
||||||
MOCK_VNF['monitoring_policy'])
|
MOCK_VNF['monitoring_policy'])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,7 +118,7 @@ class TestVNFMonitor(testtools.TestCase):
|
||||||
'id': MOCK_VNF_ID,
|
'id': MOCK_VNF_ID,
|
||||||
'mgmt_ip_address': '{"vdu1": "a.b.c.d"}',
|
'mgmt_ip_address': '{"vdu1": "a.b.c.d"}',
|
||||||
'attributes': {
|
'attributes': {
|
||||||
'monitoring_policy': json.dumps(
|
'monitoring_policy': jsonutils.dump_as_bytes(
|
||||||
MOCK_VNF['monitoring_policy'])
|
MOCK_VNF['monitoring_policy'])
|
||||||
},
|
},
|
||||||
'status': 'ACTIVE'
|
'status': 'ACTIVE'
|
||||||
|
@ -167,7 +166,7 @@ class TestVNFMonitor(testtools.TestCase):
|
||||||
'id': MOCK_VNF_ID,
|
'id': MOCK_VNF_ID,
|
||||||
'mgmt_ip_address': '{"vdu1": "a.b.c.d"}',
|
'mgmt_ip_address': '{"vdu1": "a.b.c.d"}',
|
||||||
'attributes': {
|
'attributes': {
|
||||||
'monitoring_policy': json.dumps(
|
'monitoring_policy': jsonutils.dump_as_bytes(
|
||||||
MOCK_VNF_DEVICE_FOR_VDU_AUTOHEAL['monitoring_policy'])
|
MOCK_VNF_DEVICE_FOR_VDU_AUTOHEAL['monitoring_policy'])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -191,7 +190,7 @@ class TestVNFMonitor(testtools.TestCase):
|
||||||
'id': MOCK_VNF_ID,
|
'id': MOCK_VNF_ID,
|
||||||
'mgmt_ip_address': '{"vdu1": "a.b.c.d"}',
|
'mgmt_ip_address': '{"vdu1": "a.b.c.d"}',
|
||||||
'attributes': {
|
'attributes': {
|
||||||
'monitoring_policy': json.dumps(
|
'monitoring_policy': jsonutils.dump_as_bytes(
|
||||||
MOCK_VNF['monitoring_policy'])
|
MOCK_VNF['monitoring_policy'])
|
||||||
},
|
},
|
||||||
'status': 'ACTIVE',
|
'status': 'ACTIVE',
|
||||||
|
|
Loading…
Reference in New Issue