Merge "Support hacking 6.1.0"

This commit is contained in:
Zuul 2024-05-03 19:51:51 +00:00 committed by Gerrit Code Review
commit e9c18c7f94
25 changed files with 125 additions and 120 deletions

View File

@ -217,7 +217,7 @@ class APIVersionRequest(utils.ComparableMixin):
def matches_versioned_method(self, method):
"""Compares this version to that of a versioned method."""
if type(method) != versioned_method.VersionedMethod:
if type(method) is not versioned_method.VersionedMethod:
msg = _('An API version request must be compared '
'to a VersionedMethod object.')
raise exception.InvalidParameterValue(err=msg)

View File

@ -945,7 +945,7 @@ class BackupCephTestCase(test.TestCase):
src_snap = ''
with tempfile.NamedTemporaryFile() as dest_file:
with mock.patch.object(self.service,
'_transfer_data') as mock_transfer_data,\
'_transfer_data') as mock_transfer_data, \
mock.patch.object(self.service,
'_get_backup_base_name') as mock_getbasename:
@ -963,7 +963,7 @@ class BackupCephTestCase(test.TestCase):
src_snap = 'random_snap'
with tempfile.NamedTemporaryFile() as dest_file:
with mock.patch.object(self.service,
'_transfer_data') as mock_transfer_data,\
'_transfer_data') as mock_transfer_data, \
mock.patch.object(self.service,
'_get_backup_base_name') as mock_getbasename:
@ -993,7 +993,7 @@ class BackupCephTestCase(test.TestCase):
with tempfile.NamedTemporaryFile() as dest_file:
with mock.patch.object(self.service,
'_transfer_data') as mock_transfer_data,\
'_transfer_data') as mock_transfer_data, \
mock.patch.object(self.service,
'_get_backup_base_name') as mock_getbasename:
@ -1010,7 +1010,7 @@ class BackupCephTestCase(test.TestCase):
src_snap = None
with tempfile.NamedTemporaryFile() as dest_file:
with mock.patch.object(self.service,
'_get_backup_base_name') as mock_name,\
'_get_backup_base_name') as mock_name, \
mock.patch('eventlet.tpool.Proxy') as mock_proxy:
self.mock_rbd.Image.side_effect = self.mock_rbd.ImageNotFound

View File

@ -76,7 +76,7 @@ class TestBaseISCSITargetDriver(tf.TargetDriverFixture):
def test_do_iscsi_discovery(self):
with mock.patch.object(self.configuration,
'safe_get', return_value='127.0.0.1'),\
'safe_get', return_value='127.0.0.1'), \
mock.patch('cinder.utils.execute',
return_value=(self.target_string, '')):
self.assertEqual(self.target_string,
@ -85,8 +85,8 @@ class TestBaseISCSITargetDriver(tf.TargetDriverFixture):
def test_remove_export(self):
with mock.patch.object(self.target, '_get_target_and_lun') as \
mock_get_target,\
mock.patch.object(self.target, 'show_target'),\
mock_get_target, \
mock.patch.object(self.target, 'show_target'), \
mock.patch.object(self.target, 'remove_iscsi_target') as \
mock_remove_target:
@ -103,8 +103,8 @@ class TestBaseISCSITargetDriver(tf.TargetDriverFixture):
def test_remove_export_notfound(self):
with mock.patch.object(self.target, '_get_target_and_lun') as \
mock_get_target,\
mock.patch.object(self.target, 'show_target'),\
mock_get_target, \
mock.patch.object(self.target, 'show_target'), \
mock.patch.object(self.target, 'remove_iscsi_target'):
mock_get_target.side_effect = exception.NotFound
@ -115,8 +115,8 @@ class TestBaseISCSITargetDriver(tf.TargetDriverFixture):
def test_remove_export_show_error(self):
with mock.patch.object(self.target, '_get_target_and_lun') as \
mock_get_target,\
mock.patch.object(self.target, 'show_target') as mshow,\
mock_get_target, \
mock.patch.object(self.target, 'show_target') as mshow, \
mock.patch.object(self.target, 'remove_iscsi_target'):
mock_get_target.return_value = (0, 1)

View File

@ -43,7 +43,7 @@ class TestCxtAdmDriver(tf.TargetDriverFixture):
def test_get_target(self):
with mock.patch.object(self.target, '_get_volumes_dir',
return_value=self.fake_volumes_dir),\
return_value=self.fake_volumes_dir), \
mock.patch('cinder.utils.execute',
return_value=(self.fake_iscsi_scan, None)) as m_exec:
self.assertEqual(

View File

@ -153,18 +153,19 @@ class TestSCSTAdmDriver(tf.TargetDriverFixture):
'QZJbisGmn9AL954FNF4D P68eE7u9eFqDGexd28DQ'}
with mock.patch.object(self.target, '_get_target_and_lun',
side_effect=_fake_get_target_and_lun),\
side_effect=_fake_get_target_and_lun), \
mock.patch.object(self.target, '_get_target_chap_auth',
side_effect=_fake_get_target_chap_auth),\
side_effect=_fake_get_target_chap_auth), \
mock.patch.object(self.target, 'initiator_iqn',
return_value='iqn.1993-08.org.debian:'
'01:626bf14ebdc'),\
'01:626bf14ebdc'), \
mock.patch.object(self.target, '_iscsi_location',
side_effect=_fake_iscsi_location),\
side_effect=_fake_iscsi_location), \
mock.patch.object(self.target, 'target_driver',
return_value='iscsi'),\
return_value='iscsi'), \
mock.patch.object(volume_utils, 'generate_username',
side_effect=lambda: 'QZJbisGmn9AL954FNF4D'),\
side_effect=
lambda: 'QZJbisGmn9AL954FNF4D'), \
mock.patch.object(volume_utils, 'generate_password',
side_effect=lambda: 'P68eE7u9eFqDGexd28DQ'):
self.assertEqual(expected_result,
@ -189,9 +190,9 @@ class TestSCSTAdmDriver(tf.TargetDriverFixture):
def _fake_get_target_chap_auth(*args, **kwargs):
return ('QZJbisGmn9AL954FNF4D', 'P68eE7u9eFqDGexd28DQ')
with mock.patch.object(self.target, 'create_iscsi_target'),\
with mock.patch.object(self.target, 'create_iscsi_target'), \
mock.patch.object(self.target, '_get_target_chap_auth',
side_effect=_fake_get_target_chap_auth),\
side_effect=_fake_get_target_chap_auth), \
mock.patch.object(self.target, '_get_target_and_lun',
side_effect=_fake_get_target_and_lun):
self.target.ensure_export(ctxt,
@ -219,9 +220,9 @@ class TestSCSTAdmDriver(tf.TargetDriverFixture):
def _fake_get_target_chap_auth(*args, **kwargs):
return None
with mock.patch.object(self.target, 'create_iscsi_target'),\
with mock.patch.object(self.target, 'create_iscsi_target'), \
mock.patch.object(self.target, '_get_target_chap_auth',
side_effect=_fake_get_target_chap_auth),\
side_effect=_fake_get_target_chap_auth), \
mock.patch.object(self.target, '_get_target_and_lun',
side_effect=_fake_get_target_and_lun):
self.target.ensure_export(ctxt,

View File

@ -142,9 +142,9 @@ class TestTgtAdmDriver(tf.TargetDriverFixture):
@test.testtools.skipIf(sys.platform == "darwin", "SKIP on OSX")
def test_create_iscsi_target(self):
with mock.patch('cinder.privsep.targets.tgt.tgtadm_show',
return_value=('', '')),\
return_value=('', '')), \
mock.patch.object(self.target, '_get_target',
side_effect=lambda x: 1),\
side_effect=lambda x: 1), \
mock.patch('cinder.privsep.targets.tgt.tgtadmin_update',
return_value=('', '')), \
mock.patch.object(self.target, '_verify_backing_lun',
@ -165,11 +165,11 @@ class TestTgtAdmDriver(tf.TargetDriverFixture):
mock_open = mock.mock_open()
with mock.patch('cinder.privsep.targets.tgt.tgtadm_show',
return_value=('', '')),\
return_value=('', '')), \
mock.patch.object(self.target, '_get_target',
side_effect=lambda x: 1),\
side_effect=lambda x: 1), \
mock.patch.object(self.target, '_verify_backing_lun',
side_effect=lambda x, y: True),\
side_effect=lambda x, y: True), \
mock.patch('cinder.privsep.targets.tgt.tgtadmin_update',
return_value=('', '')), \
mock.patch('cinder.volume.targets.tgt.open',
@ -196,9 +196,9 @@ class TestTgtAdmDriver(tf.TargetDriverFixture):
return 'fake out', 'fake err'
with mock.patch.object(self.target, '_get_target',
side_effect=lambda x: 1),\
side_effect=lambda x: 1), \
mock.patch.object(self.target, '_verify_backing_lun',
side_effect=lambda x, y: True),\
side_effect=lambda x, y: True), \
mock.patch('cinder.privsep.targets.tgt.tgtadmin_update',
return_value=('', '')), \
mock.patch('cinder.privsep.targets.tgt.tgtadm_show',
@ -344,15 +344,15 @@ class TestTgtAdmDriver(tf.TargetDriverFixture):
'auth': 'CHAP QZJb P68e'}
with mock.patch('cinder.privsep.targets.tgt.tgtadm_show',
return_value=('', '')),\
return_value=('', '')), \
mock.patch.object(self.target, '_get_target',
side_effect=lambda x: 1),\
side_effect=lambda x: 1), \
mock.patch.object(self.target, '_verify_backing_lun',
side_effect=lambda x, y: True),\
side_effect=lambda x, y: True), \
mock.patch.object(self.target, '_get_target_chap_auth',
side_effect=lambda x, y: None) as m_chap,\
side_effect=lambda x, y: None) as m_chap, \
mock.patch.object(volume_utils, 'generate_username',
side_effect=lambda: 'QZJb'),\
side_effect=lambda: 'QZJb'), \
mock.patch('cinder.privsep.targets.tgt.tgtadmin_update',
return_value=('', '')), \
mock.patch.object(volume_utils, 'generate_password',
@ -393,9 +393,9 @@ class TestTgtAdmDriver(tf.TargetDriverFixture):
@test.testtools.skipIf(sys.platform == "darwin", "SKIP on OSX")
def test_create_iscsi_target_retry(self):
with mock.patch('cinder.privsep.targets.tgt.tgtadm_show',
return_value=('', '')),\
return_value=('', '')), \
mock.patch.object(self.target, '_get_target',
side_effect=[None, None, 1]) as get_target,\
side_effect=[None, None, 1]) as get_target, \
mock.patch('cinder.privsep.targets.tgt.tgtadmin_update',
return_value=('', '')), \
mock.patch.object(self.target, '_verify_backing_lun',

View File

@ -135,7 +135,7 @@ class TestCleanableManager(test.TestCase):
clean_req = objects.CleanupRequest(service_id=self.service.id)
mngr = FakeManager(self.service.id)
with mock.patch('cinder.manager.timeutils.utcnow', return_value=now),\
with mock.patch('cinder.manager.timeutils.utcnow', return_value=now), \
mock.patch('cinder.db.worker_get_all') as get_all_mock:
get_all_mock.return_value = [worker1, worker2]
mngr.do_cleanup(self.context, clean_req)

View File

@ -2001,7 +2001,7 @@ class TestHPE3PARDriverBase(HPE3PARBaseDriver):
VOLUME_INFO_0 = self.RETYPE_VOLUME_INFO_0.copy()
# volume without comment
del(VOLUME_INFO_0['comment'])
del (VOLUME_INFO_0['comment'])
mock_client.getVolume.return_value = VOLUME_INFO_0
with mock.patch.object(hpecommon.HPE3PARCommon,

View File

@ -9187,7 +9187,7 @@ class StorwizeSVCCommonDriverTestCase(test.TestCase):
host='openstack@svc#hyperswap1',
volume_type_id=hyper_type.id)
with (mock.patch.object(storwize_svc_common.StorwizeHelpers,
'convert_volume_to_hyperswap')) as convert_volume_to_hyperswap,\
'convert_volume_to_hyperswap')) as convert_volume_to_hyperswap, \
(mock.patch.object(storwize_svc_common.StorwizeHelpers,
'ensure_vdisk_no_fc_mappings')) as ensure_vdisk_no_fc_mappings:
self.driver.create_volume_from_snapshot(vol2, snap)
@ -10063,7 +10063,7 @@ class StorwizeSVCCommonDriverTestCase(test.TestCase):
[clone_vol1, clone_vol2])
with (mock.patch.object(storwize_svc_common.StorwizeHelpers,
'convert_volume_to_hyperswap')) as convert_volume_to_hyperswap,\
'convert_volume_to_hyperswap')) as convert_volume_to_hyperswap, \
(mock.patch.object(storwize_svc_common.StorwizeHelpers,
'ensure_vdisk_no_fc_mappings')) as ensure_vdisk_no_fc_mappings:
@ -10189,7 +10189,7 @@ class StorwizeSVCCommonDriverTestCase(test.TestCase):
[clone_vol1, clone_vol2])
with (mock.patch.object(storwize_svc_common.StorwizeHelpers,
'convert_volume_to_hyperswap')) as convert_volume_to_hyperswap,\
'convert_volume_to_hyperswap')) as convert_volume_to_hyperswap, \
(mock.patch.object(storwize_svc_common.StorwizeHelpers,
'ensure_vdisk_no_fc_mappings')) as ensure_vdisk_no_fc_mappings:
@ -11470,7 +11470,7 @@ class StorwizeSSHTestCase(test.TestCase):
opt = {'iogrp': 0}
with mock.patch.object(storwize_svc_common.StorwizeSSH,
'run_ssh_check_created',
side_effect=run_ssh_check),\
side_effect=run_ssh_check), \
mock.patch.object(storwize_svc_common.StorwizeSSH, 'lsvdisk',
return_value=lsvol):
if lsvol:

View File

@ -890,9 +890,9 @@ class AS13000DriverTestCase(test.TestCase):
mock_tnd = self.mock_object(self.as13000_san, '_trans_name_down',
mock.Mock(return_value='fake_volume'))
fake_target_list = [{'hostIp': ['fake_hostIp'],
'name':'target_name',
'lun':[{'lvm': 'fake_volume',
'lunID': 'fake_id'}]}]
'name': 'target_name',
'lun': [{'lvm': 'fake_volume',
'lunID': 'fake_id'}]}]
mock_gtl = self.mock_object(self.as13000_san, '_get_target_list',
mock.Mock(return_value=fake_target_list))
mock_dlft = self.mock_object(self.as13000_san,
@ -978,8 +978,8 @@ class AS13000DriverTestCase(test.TestCase):
target_list = [
{
'hostIp': ['fake_ip1', 'fake_ip2'],
'name':'fake_target_1',
'node':['fake_node1', 'fake_node2']
'name': 'fake_target_1',
'node': ['fake_node1', 'fake_node2']
},
{
'hostIp': ['fake_ip3', 'fake_ip4'],

View File

@ -1522,7 +1522,7 @@ class TestOpenEJovianDSSDriver(test.TestCase):
get_vol['volsize'] = "1073145824"
jdssd.ra.get_lun.return_value = get_vol
with mock.patch.object(jdssd, '_clone_object'),\
with mock.patch.object(jdssd, '_clone_object'), \
mock.patch.object(jdssd, "resize_volume"):
jdssd.create_cloned_volume(UUID_2, UUID_1, 1, sparse=False)

View File

@ -589,9 +589,9 @@ class SolidFireVolumeTestCase(test.TestCase):
'_get_sfaccounts_for_tenant',
return_value=[{'accountID': 5,
'username':
'prefix-testprjid'}]),\
'prefix-testprjid'}]), \
mock.patch.object(sfv, '_retrieve_replication_settings',
return_value=["Async", {}]),\
return_value=["Async", {}]), \
mock.patch.object(sfv, '_get_sf_volume',
return_value={'volumeID': 33}):
sfv.create_snapshot(testsnap)
@ -2369,7 +2369,7 @@ class SolidFireVolumeTestCase(test.TestCase):
{'name': prefix + 'three'}]
with mock.patch.object(sfv,
'_get_all_active_volumes',
return_value=active_vols),\
return_value=active_vols), \
mock.patch.object(sfv,
'_sf_create_group_snapshot',
return_value=None) as create:
@ -2439,7 +2439,7 @@ class SolidFireVolumeTestCase(test.TestCase):
fake_gsnap = {'groupSnapshotID': 42}
with mock.patch.object(sfv,
'_get_group_snapshot_by_name',
return_value=fake_gsnap),\
return_value=fake_gsnap), \
mock.patch.object(sfv,
'_delete_group_snapshot') as del_stuff:
sfv._delete_cgsnapshot_by_name('does not matter')
@ -2480,9 +2480,9 @@ class SolidFireVolumeTestCase(test.TestCase):
kek = (None, None, {})
with mock.patch.object(sfv,
'_get_group_snapshot_by_name',
return_value=group_snap) as get_snap,\
return_value=group_snap) as get_snap, \
mock.patch.object(sfv,
'_find_linked_snapshot'),\
'_find_linked_snapshot'), \
mock.patch.object(sfv,
'_do_clone_volume',
return_value=kek):
@ -2510,16 +2510,16 @@ class SolidFireVolumeTestCase(test.TestCase):
kek = (None, None, {})
with mock.patch.object(sfv,
'_create_temp_group_snapshot',
return_value=source_cg['id']),\
return_value=source_cg['id']), \
mock.patch.object(sfv,
'_get_group_snapshot_by_name',
return_value=group_snap) as get_snap,\
return_value=group_snap) as get_snap, \
mock.patch.object(sfv,
'_find_linked_snapshot',
return_value=source_snap),\
return_value=source_snap), \
mock.patch.object(sfv,
'_do_clone_volume',
return_value=kek),\
return_value=kek), \
mock.patch.object(sfv,
'_delete_cgsnapshot_by_name'):
model, vol_models = sfv._create_consistencygroup_from_src(
@ -2542,7 +2542,7 @@ class SolidFireVolumeTestCase(test.TestCase):
{'name': pfx + 'two'}]
with mock.patch.object(sfv,
'_get_all_active_volumes',
return_value=active_vols),\
return_value=active_vols), \
mock.patch.object(sfv,
'_sf_create_group_snapshot') as create_gsnap:
sfv._create_cgsnapshot(ctxt, cgsnapshot, snapshots)
@ -2559,7 +2559,7 @@ class SolidFireVolumeTestCase(test.TestCase):
active_vols = [{'name': pfx + 'one'}]
with mock.patch.object(sfv,
'_get_all_active_volumes',
return_value=active_vols),\
return_value=active_vols), \
mock.patch.object(sfv,
'_sf_create_group_snapshot'):
self.assertRaises(solidfire.SolidFireDriverException,
@ -2579,7 +2579,7 @@ class SolidFireVolumeTestCase(test.TestCase):
source.get('group_snapshot_id'))
with mock.patch.object(sfv,
'_get_group_snapshot_by_name',
return_value={}) as get,\
return_value={}) as get, \
mock.patch.object(sfv,
'_create_clone_from_sf_snapshot',
return_value='model'):
@ -2787,10 +2787,10 @@ class SolidFireVolumeTestCase(test.TestCase):
with mock.patch.object(sfv,
'_issue_api_request',
self.fake_issue_api_request),\
self.fake_issue_api_request), \
mock.patch.object(sfv,
'_get_sfaccount_by_name',
return_value={'accountID': 1}),\
return_value={'accountID': 1}), \
mock.patch.object(sfv,
'_do_volume_create',
return_value=model_update):
@ -2806,13 +2806,13 @@ class SolidFireVolumeTestCase(test.TestCase):
sfv = solidfire.SolidFireDriver(configuration=self.configuration)
with mock.patch.object(sfv,
'_get_create_account',
return_value={'accountID': 5}),\
return_value={'accountID': 5}), \
mock.patch.object(sfv,
'_retrieve_qos_setting',
return_value=None), \
mock.patch.object(sfv,
'_do_volume_create',
return_value={'provider_id': '1 2 xxxx'}),\
return_value={'provider_id': '1 2 xxxx'}), \
mock.patch.object(volume_types,
'get_volume_type',
return_value=fake_type), \

View File

@ -784,20 +784,20 @@ class LVMVolumeDriverTestCase(test_driver.BaseDriverTestCase):
self.context, fake_volume.id)
with mock.patch.object(self.volume.driver.vg,
'revert') as mock_revert,\
'revert') as mock_revert, \
mock.patch.object(self.volume.driver.vg,
'create_lv_snapshot') as mock_create,\
'create_lv_snapshot') as mock_create, \
mock.patch.object(self.volume.driver.vg,
'deactivate_lv') as mock_deactive,\
'deactivate_lv') as mock_deactivate, \
mock.patch.object(self.volume.driver.vg,
'activate_lv') as mock_active:
'activate_lv') as mock_activate:
self.volume.driver.revert_to_snapshot(self.context,
fake_volume,
fake_snapshot)
mock_revert.assert_called_once_with(
self.volume.driver._escape_snapshot(fake_snapshot.name))
mock_deactive.assert_called_once_with(fake_volume.name)
mock_active.assert_called_once_with(fake_volume.name)
mock_deactivate.assert_called_once_with(fake_volume.name)
mock_activate.assert_called_once_with(fake_volume.name)
mock_create.assert_called_once_with(
self.volume.driver._escape_snapshot(fake_snapshot.name),
fake_volume.name, self.configuration.lvm_type)

View File

@ -327,7 +327,7 @@ class TestSeagateClient(test.TestCase):
RequestException("error")]
mock_requests_get.return_value = m
ret = self.client._api_request('/path')
self.assertTrue(type(ret) == etree._Element)
self.assertTrue(type(ret) is etree._Element)
self.assertRaises(stx_exception.ConnectionError,
self.client._api_request,
'/path')

View File

@ -244,8 +244,8 @@ class SnapshotTestCase(base.BaseVolumeTestCase):
mock_get.return_value = test_volume
volume_api = cinder.volume.api.API()
with mock.patch.object(QUOTAS, 'add_volume_type_opts'),\
mock.patch.object(QUOTAS, 'reserve') as mock_reserve,\
with mock.patch.object(QUOTAS, 'add_volume_type_opts'), \
mock.patch.object(QUOTAS, 'reserve') as mock_reserve, \
mock.patch.object(QUOTAS, 'commit') as mock_commit:
self.assertRaises(exception.InvalidInput,
volume_api.create_snapshot_in_db,

View File

@ -2253,9 +2253,9 @@ class VolumeTestCase(base.BaseVolumeTestCase):
fake_volume.id)
with mock.patch.object(
self.volume.driver,
'_create_temp_volume_from_snapshot') as mock_temp,\
'_create_temp_volume_from_snapshot') as mock_temp, \
mock.patch.object(
self.volume.driver, 'delete_volume') as mock_driver_delete,\
self.volume.driver, 'delete_volume') as mock_driver_delete, \
mock.patch.object(
self.volume, '_copy_volume_data') as mock_copy:
temp_volume = tests_utils.create_volume(self.context,
@ -2277,7 +2277,7 @@ class VolumeTestCase(base.BaseVolumeTestCase):
with mock.patch.object(self.volume.driver,
'revert_to_snapshot') as driver_revert, \
mock.patch.object(self.volume, '_notify_about_volume_usage'), \
mock.patch.object(self.volume, '_notify_about_snapshot_usage'),\
mock.patch.object(self.volume, '_notify_about_snapshot_usage'), \
mock.patch.object(self.volume,
'_revert_to_snapshot_generic') as generic_revert:
if driver_error:
@ -2307,9 +2307,9 @@ class VolumeTestCase(base.BaseVolumeTestCase):
status='restoring',
volume_size=1)
with mock.patch.object(self.volume,
'_revert_to_snapshot') as _revert,\
'_revert_to_snapshot') as _revert, \
mock.patch.object(self.volume,
'_create_backup_snapshot') as _create_snapshot,\
'_create_backup_snapshot') as _create_snapshot, \
mock.patch.object(self.volume,
'delete_snapshot') as _delete_snapshot, \
mock.patch.object(self.volume.driver,

View File

@ -134,7 +134,7 @@ class VolumeMigrationTestCase(base.BaseVolumeTestCase):
def test_migrate_volume_error(self):
with mock.patch.object(self.volume.driver, 'migrate_volume') as \
mock_migrate,\
mock_migrate, \
mock.patch.object(self.volume.driver, 'create_export') as \
mock_create_export:
@ -338,8 +338,8 @@ class VolumeMigrationTestCase(base.BaseVolumeTestCase):
host_obj = {'host': 'newhost', 'capabilities': {}}
with mock.patch.object(self.volume.driver, 'migrate_volume') as \
mock_migrate_volume,\
mock.patch.object(self.volume, '_copy_volume_data'),\
mock_migrate_volume, \
mock.patch.object(self.volume, '_copy_volume_data'), \
mock.patch.object(self.volume.driver, 'delete_volume') as \
delete_volume:
create_volume.side_effect = self._fake_create_volume
@ -355,13 +355,13 @@ class VolumeMigrationTestCase(base.BaseVolumeTestCase):
self.assertTrue(update_migrated_volume.called)
def test_migrate_volume_generic_copy_error(self):
with mock.patch.object(self.volume.driver, 'migrate_volume'),\
mock.patch.object(volume_rpcapi.VolumeAPI, 'create_volume')\
as mock_create_volume,\
with mock.patch.object(self.volume.driver, 'migrate_volume'), \
mock.patch.object(volume_rpcapi.VolumeAPI, 'create_volume') \
as mock_create_volume, \
mock.patch.object(self.volume, '_copy_volume_data') as \
mock_copy_volume,\
mock.patch.object(volume_rpcapi.VolumeAPI, 'delete_volume'),\
mock.patch.object(self.volume, 'migrate_volume_completion'),\
mock_copy_volume, \
mock.patch.object(volume_rpcapi.VolumeAPI, 'delete_volume'), \
mock.patch.object(self.volume, 'migrate_volume_completion'), \
mock.patch.object(self.volume.driver, 'create_export'):
# Exception case at migrate_volume_generic
@ -434,7 +434,7 @@ class VolumeMigrationTestCase(base.BaseVolumeTestCase):
expected_update = {'_name_id': volume._name_id,
'provider_location': volume.provider_location}
with mock.patch.object(self.volume.driver,
'update_migrated_volume') as migrate_update,\
'update_migrated_volume') as migrate_update, \
mock.patch.object(self.context, 'elevated') as elevated:
migrate_update.return_value = fake_update
elevated.return_value = fake_elevated
@ -516,13 +516,13 @@ class VolumeMigrationTestCase(base.BaseVolumeTestCase):
self.expected_status = 'available'
def test_migrate_volume_generic_create_export_error(self):
with mock.patch.object(self.volume.driver, 'migrate_volume'),\
mock.patch.object(volume_rpcapi.VolumeAPI, 'create_volume')\
as mock_create_volume,\
with mock.patch.object(self.volume.driver, 'migrate_volume'), \
mock.patch.object(volume_rpcapi.VolumeAPI, 'create_volume') \
as mock_create_volume, \
mock.patch.object(self.volume, '_copy_volume_data') as \
mock_copy_volume,\
mock.patch.object(volume_rpcapi.VolumeAPI, 'delete_volume'),\
mock.patch.object(self.volume, 'migrate_volume_completion'),\
mock_copy_volume, \
mock.patch.object(volume_rpcapi.VolumeAPI, 'delete_volume'), \
mock.patch.object(self.volume, 'migrate_volume_completion'), \
mock.patch.object(self.volume.driver, 'create_export') as \
mock_create_export:
@ -551,12 +551,12 @@ class VolumeMigrationTestCase(base.BaseVolumeTestCase):
{'migration_status': 'completing'})
raise processutils.ProcessExecutionError
with mock.patch.object(self.volume.driver, 'migrate_volume'),\
with mock.patch.object(self.volume.driver, 'migrate_volume'), \
mock.patch.object(volume_rpcapi.VolumeAPI, 'create_volume')\
as mock_create_volume,\
mock.patch.object(volume_rpcapi.VolumeAPI, 'delete_volume'),\
as mock_create_volume, \
mock.patch.object(volume_rpcapi.VolumeAPI, 'delete_volume'), \
mock.patch.object(self.volume, 'migrate_volume_completion')\
as mock_migrate_compl,\
as mock_migrate_compl, \
mock.patch.object(self.volume.driver, 'create_export'), \
mock.patch.object(self.volume, '_attach_volume') \
as mock_attach, \
@ -623,11 +623,11 @@ class VolumeMigrationTestCase(base.BaseVolumeTestCase):
host=new_host,
migration_status=target_status)
with mock.patch.object(self.volume, 'detach_volume') as \
mock_detach_volume,\
mock_detach_volume, \
mock.patch.object(volume_rpcapi.VolumeAPI,
'delete_volume') as mock_delete_volume,\
'delete_volume') as mock_delete_volume, \
mock.patch.object(volume_rpcapi.VolumeAPI,
'attach_volume') as mock_attach_volume,\
'attach_volume') as mock_attach_volume, \
mock.patch.object(volume_rpcapi.VolumeAPI,
'update_migrated_volume'):
mock_attach_volume.side_effect = self.fake_attach_volume
@ -810,11 +810,13 @@ class VolumeMigrationTestCase(base.BaseVolumeTestCase):
old_usage = db.quota_usage_get_all_by_project(elevated, project_id)
with mock.patch.object(self.volume.driver, 'retype') as _retype,\
mock.patch.object(volume_types, 'volume_types_diff') as _diff,\
mock.patch.object(self.volume, 'migrate_volume') as _mig,\
mock.patch.object(db.sqlalchemy.api, 'volume_get') as _vget,\
mock.patch.object(context.RequestContext, 'elevated') as _ctx,\
with mock.patch.object(self.volume.driver, 'retype') as _retype, \
mock.patch.object(volume_types,
'volume_types_diff') as _diff, \
mock.patch.object(self.volume, 'migrate_volume') as _mig, \
mock.patch.object(db.sqlalchemy.api, 'volume_get') as _vget, \
mock.patch.object(context.RequestContext,
'elevated') as _ctx, \
mock.patch.object(objects.VolumeType, 'get_by_id') as _vtget:
_vget.return_value = volume
_retype.return_value = driver
@ -1014,7 +1016,7 @@ class VolumeMigrationTestCase(base.BaseVolumeTestCase):
replication_status='not-capable')
host_obj = {'host': 'newhost', 'capabilities': {}}
with mock.patch.object(self.volume,
'migrate_volume') as migrate_volume,\
'migrate_volume') as migrate_volume, \
mock.patch.object(objects.VolumeType,
'get_by_id') as vt_get:
migrate_volume.return_value = True

View File

@ -795,7 +795,7 @@ class ApiClient(object):
if data is None:
return None
if type(klass) == str:
if type(klass) is str:
if klass.startswith('list['):
sub_kls = re.match(r'list\[(.*)\]', klass).group(1)
return [self.__deserialize(sub_data, sub_kls)

View File

@ -1594,7 +1594,7 @@ class NimbleRestAPIExecutor(object):
LOG.debug("Key %(key)s Value %(value)s",
{'key': key, 'value': value})
if key == EXTRA_SPEC_IOPS_LIMIT and value.isdigit():
if type(value) == int or int(value) < MIN_IOPS or (
if type(value) is int or int(value) < MIN_IOPS or (
int(value) > MAX_IOPS):
raise NimbleAPIException(_("%(err)s [%(min)s, %(max)s]") %
{'err': IOPS_ERR_MSG,
@ -2066,7 +2066,7 @@ class NimbleRestAPIExecutor(object):
LOG.debug("Key %(key)s Value %(value)s",
{'key': key, 'value': value})
if key == EXTRA_SPEC_IOPS_LIMIT and value.isdigit():
if type(value) == int or int(value) < MIN_IOPS or (
if type(value) is int or int(value) < MIN_IOPS or (
int(value) > MAX_IOPS):
raise NimbleAPIException(_("Please enter valid IOPS "
"limit in the range ["

View File

@ -53,7 +53,7 @@ class STXFCDriver(cinder.volume.driver.FibreChannelDriver):
self.common = None
self.configuration.append_config_values(san.san_opts)
self.lookup_service = fczm_utils.create_lookup_service()
if type(self) != STXFCDriver:
if type(self) is not STXFCDriver:
return
self.configuration.append_config_values(common.common_opts)

View File

@ -62,7 +62,7 @@ class STXISCSIDriver(cinder.volume.driver.ISCSIDriver):
super(STXISCSIDriver, self).__init__(*args, **kwargs)
self.common = None
self.configuration.append_config_values(san.san_opts)
if type(self) != STXISCSIDriver:
if type(self) is not STXISCSIDriver:
return
self.configuration.append_config_values(common.common_opts)
self.configuration.append_config_values(common.iscsi_opts)
@ -154,7 +154,7 @@ class STXISCSIDriver(cinder.volume.driver.ISCSIDriver):
self.common.client_logout()
def terminate_connection(self, volume, connector, **kwargs):
if type(connector) == dict and 'initiator' in connector:
if type(connector) is dict and 'initiator' in connector:
# multiattach volumes cannot be unmapped here, but will
# be implicity unmapped when the volume is deleted.
if not volume.get('multiattach'):

View File

@ -245,7 +245,7 @@ class TydsClient(object):
- target_block_name: The name of the target block.
"""
pool_name, block_name, block_id, target_pool_name, target_pool_id,\
pool_name, block_name, block_id, target_pool_name, target_pool_id, \
target_block_name = args
params = {
'poolName': pool_name,

View File

@ -3079,7 +3079,7 @@ class VolumeManager(manager.CleanableManager,
host)
# Check if the driver retype provided a model update or
# just a retype indication
if type(ret) == tuple:
if type(ret) is tuple:
retyped, retype_model_update = ret
else:
retyped = ret

View File

@ -3,7 +3,7 @@
# process, which may cause wedges in the gate later.
# Install bounded pep8/pyflakes first, then let flake8 install
hacking>=5.0.0,<5.1.0 # Apache-2.0
hacking>=6.1.0,<6.2.0 # Apache-2.0
flake8-import-order # LGPLv3
flake8-logging-format>=0.6.0 # Apache-2.0

View File

@ -233,7 +233,9 @@ commands =
#
# E251 unexpected spaces around keyword / parameter equals
# reason: no improvement in readability
#
# E275: missing whitespace after keyword
# reason: many failures newly triggered in pycodestyle 2.9.0,
# evaluate if fixing is worthwhile
# E402 module level import not at top of file
# reason: there are numerous places where we import modules
# later for legitimate reasons
@ -249,7 +251,7 @@ commands =
# reason: no real benefit
# G200 Logging statements should not include the exception
# reason: Many existing cases of this that may be legitimate
ignore = E251,E402,W503,W504,H101,G200
ignore = E251,E275,E402,W503,W504,H101,G200
# H904 Delay string interpolations at logging calls.
enable-extensions = H106,H203,H904
exclude = .git,.venv,.tox,dist,tools,doc/ext,*egg,build