diff --git a/cinder/tests/unit/volume/drivers/dell_emc/test_vmax.py b/cinder/tests/unit/volume/drivers/dell_emc/test_vmax.py index d4661c0604c..ae2ec84ed95 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/test_vmax.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/test_vmax.py @@ -8662,7 +8662,7 @@ class VMAXUtilsTest(test.TestCase): self.driver.utils.insert_live_migration_record( self.data.test_volume, maskingviewdict, connector, extraSpecs) mock_open.assert_called_once_with( - utils.LIVE_MIGRATION_FILE, "wb") + utils.LIVE_MIGRATION_FILE, "w") @mock.patch.object( common.VMAXCommon, @@ -8685,12 +8685,12 @@ class VMAXUtilsTest(test.TestCase): '/livemigrationarray') m = mock.mock_open() with mock.patch('{}.open'.format(__name__), m, create=True): - with open(utils.LIVE_MIGRATION_FILE, "wb") as f: + with open(utils.LIVE_MIGRATION_FILE, "w") as f: f.write('live migration details') self.driver.utils.insert_live_migration_record( self.data.test_volume, maskingviewdict, connector, extraSpecs) self.driver.utils.delete_live_migration_record(self.data.test_volume) - m.assert_called_once_with(utils.LIVE_MIGRATION_FILE, "wb") + m.assert_called_once_with(utils.LIVE_MIGRATION_FILE, "w") shutil.rmtree(tempdir) @mock.patch.object( diff --git a/cinder/volume/drivers/dell_emc/vmax/utils.py b/cinder/volume/drivers/dell_emc/vmax/utils.py index c97408b0a6d..255da5507f9 100644 --- a/cinder/volume/drivers/dell_emc/vmax/utils.py +++ b/cinder/volume/drivers/dell_emc/vmax/utils.py @@ -17,13 +17,13 @@ import ast import datetime import hashlib import os -import pickle import random import re import time from xml.dom import minidom from oslo_log import log as logging +from oslo_serialization import jsonutils from oslo_service import loopingcall from oslo_utils import units import six @@ -2704,8 +2704,8 @@ class VMAXUtils(object): live_migration_details = {volume['id']: [maskingviewdict, connector, extraSpecs]} try: - with open(LIVE_MIGRATION_FILE, "wb") as f: - pickle.dump(live_migration_details, f) + with open(LIVE_MIGRATION_FILE, "w") as f: + jsonutils.dump(live_migration_details, f) except Exception: exceptionMessage = (_( "Error in processing live migration file.")) @@ -2725,8 +2725,8 @@ class VMAXUtils(object): if live_migration_details: if volume['id'] in live_migration_details: del live_migration_details[volume['id']] - with open(LIVE_MIGRATION_FILE, "wb") as f: - pickle.dump(live_migration_details, f) + with open(LIVE_MIGRATION_FILE, "w") as f: + jsonutils.dump(live_migration_details, f) else: LOG.debug("%(Volume)s doesn't exist in live migration " "record.", @@ -2745,7 +2745,7 @@ class VMAXUtils(object): returned_record = None if os.path.isfile(LIVE_MIGRATION_FILE): with open(LIVE_MIGRATION_FILE, "rb") as f: - live_migration_details = pickle.load(f) + live_migration_details = jsonutils.load(f) if returnallrecords: returned_record = live_migration_details else: