From 3eb9b422f43c5657740026720d1718698660413b Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Fri, 20 Dec 2019 16:06:45 -0600 Subject: [PATCH] Introduce flake8-import-order extension This adds usage of the flake8-import-order extension to our flake8 checks to enforce consistency on our import ordering to follow the overall OpenStack code guidelines. Since we have now dropped Python 2, this also cleans up a few cases for things that were third party libs but became part of the standard library such as mock, which is now a standard part of unittest. Some questions, in order of importance: Q: Are you insane? A: Potentially. Q: Why should we touch all of these files? A: This adds consistency to our imports. The extension makes sure that all imports follow our published guidelines of having imports ordered by standard lib, third party, and local. This will be a one time churn, then we can ensure consistency over time. Q: Why bother. this doesn't really matter? A: I agree - but... We have the issue that we have less people actively involved and less time to perform thorough code reviews. This will make it objective and automated to catch these kinds of issues. But part of this, even though it maybe seems a little annoying, is for making it easier for contributors. Right now, we may or may not notice if something is following the guidelines or not. And we may or may not comment in a review to ask for a contributor to make adjustments to follow the guidelines. But then further along into the review process, someone decides to be thorough, and after the contributor feels like they've had to deal with other change requests and things are in really good shape, they get a -1 on something mostly meaningless as far as the functionality of their code. It can be a frustrating and disheartening thing. I believe this actually helps avoid that by making it an objective thing that they find out right away up front - either the code is following the guidelines and everything is happy, or it's not and running local jobs or the pep8 CI job will let them know right away and they can fix it. No guessing on whether or not someone is going to take a stand on following the guidelines or not. This will also make it easier on the code reviewers. The more we can automate, the more time we can spend in code reviews making sure the logic of the change is correct and less time looking at trivial coding and style things. Q: Should we use our hacking extensions for this? A: Hacking has had to keep back linter requirements for a long time now. Current versions of the linters actually don't work with the way we've been hooking into them for our hacking checks. We will likely need to do away with those at some point so we can move on to the current linter releases. This will help ensure we have something in place when that time comes to make sure some checks are automated. Q: Didn't you spend more time on this than the benefit we'll get from it? A: Yeah, probably. Change-Id: Ic13ba238a4a45c6219f4de131cfe0366219d722f Signed-off-by: Sean McGinnis --- cinder/api/common.py | 3 +- cinder/api/contrib/quotas.py | 3 +- cinder/api/contrib/volume_image_metadata.py | 4 +-- cinder/api/openstack/wsgi.py | 13 ++----- cinder/backup/api.py | 7 ++-- cinder/cmd/api.py | 12 +++---- cinder/cmd/backup.py | 7 ++-- cinder/cmd/scheduler.py | 10 +++--- cinder/cmd/status.py | 12 +++---- cinder/cmd/volume.py | 26 +++++--------- cinder/cmd/volume_usage_audit.py | 34 +++++++++---------- cinder/db/sqlalchemy/api.py | 12 ++----- cinder/db/sqlalchemy/migrate_repo/manage.py | 4 +-- cinder/image/cache.py | 5 ++- cinder/keymgr/migration.py | 5 ++- cinder/manager.py | 7 ++-- cinder/objects/cgsnapshot.py | 3 +- cinder/objects/consistencygroup.py | 2 +- cinder/objects/group_snapshot.py | 3 +- cinder/objects/qos_specs.py | 2 +- cinder/opts.py | 3 +- cinder/quota_utils.py | 5 ++- cinder/test.py | 3 +- cinder/tests/functional/functional_helpers.py | 6 ++-- cinder/tests/functional/test_quotas.py | 2 +- cinder/tests/hacking/checks.py | 1 + .../unit/api/contrib/test_admin_actions.py | 3 +- .../contrib/test_backup_project_attribute.py | 1 - cinder/tests/unit/api/contrib/test_backups.py | 7 ++-- .../unit/api/contrib/test_capabilities.py | 2 +- .../unit/api/contrib/test_cgsnapshots.py | 8 ++--- .../api/contrib/test_consistencygroups.py | 7 ++-- .../test_extended_snapshot_attributes.py | 2 +- cinder/tests/unit/api/contrib/test_hosts.py | 2 +- .../unit/api/contrib/test_qos_specs_manage.py | 3 +- cinder/tests/unit/api/contrib/test_quotas.py | 14 +++----- .../unit/api/contrib/test_quotas_classes.py | 2 +- .../unit/api/contrib/test_scheduler_stats.py | 3 +- .../tests/unit/api/contrib/test_services.py | 3 +- .../unit/api/contrib/test_snapshot_actions.py | 3 +- .../unit/api/contrib/test_snapshot_manage.py | 3 +- .../api/contrib/test_snapshot_unmanage.py | 3 +- .../api/contrib/test_types_extra_specs.py | 3 +- .../unit/api/contrib/test_types_manage.py | 6 ++-- .../unit/api/contrib/test_used_limits.py | 3 +- .../unit/api/contrib/test_volume_actions.py | 2 +- .../api/contrib/test_volume_image_metadata.py | 2 +- .../unit/api/contrib/test_volume_manage.py | 3 +- .../unit/api/contrib/test_volume_transfer.py | 7 ++-- .../api/contrib/test_volume_type_access.py | 2 +- .../unit/api/contrib/test_volume_unmanage.py | 3 +- cinder/tests/unit/api/openstack/test_wsgi.py | 4 +-- cinder/tests/unit/api/test_common.py | 10 +++--- cinder/tests/unit/api/v2/fakes.py | 1 + .../unit/api/v2/test_snapshot_metadata.py | 2 +- cinder/tests/unit/api/v2/test_snapshots.py | 3 +- cinder/tests/unit/api/v2/test_types.py | 2 +- .../tests/unit/api/v2/test_volume_metadata.py | 2 +- cinder/tests/unit/api/v2/test_volumes.py | 4 +-- cinder/tests/unit/api/v3/fakes.py | 1 + cinder/tests/unit/api/v3/stubs.py | 1 + cinder/tests/unit/api/v3/test_attachments.py | 7 ++-- cinder/tests/unit/api/v3/test_backups.py | 3 +- cinder/tests/unit/api/v3/test_cluster.py | 2 +- .../tests/unit/api/v3/test_group_snapshots.py | 7 ++-- cinder/tests/unit/api/v3/test_group_specs.py | 8 ++--- cinder/tests/unit/api/v3/test_group_types.py | 2 +- cinder/tests/unit/api/v3/test_groups.py | 7 ++-- cinder/tests/unit/api/v3/test_limits.py | 3 +- cinder/tests/unit/api/v3/test_messages.py | 3 +- .../unit/api/v3/test_resource_filters.py | 7 ++-- .../tests/unit/api/v3/test_snapshot_manage.py | 3 +- cinder/tests/unit/api/v3/test_snapshots.py | 3 +- .../tests/unit/api/v3/test_volume_manage.py | 3 +- .../tests/unit/api/v3/test_volume_metadata.py | 2 +- .../tests/unit/api/v3/test_volume_transfer.py | 9 +++-- cinder/tests/unit/api/v3/test_volumes.py | 6 ++-- cinder/tests/unit/api/v3/test_workers.py | 3 +- .../unit/attachments/test_attachments_api.py | 3 +- .../attachments/test_attachments_manager.py | 3 +- .../unit/backup/drivers/test_backup_ceph.py | 2 +- .../backup/drivers/test_backup_driver_base.py | 2 +- .../backup/drivers/test_backup_glusterfs.py | 7 ++-- .../unit/backup/drivers/test_backup_google.py | 7 ++-- .../unit/backup/drivers/test_backup_nfs.py | 8 ++--- .../unit/backup/drivers/test_backup_posix.py | 7 ++-- .../unit/backup/drivers/test_backup_swift.py | 9 ++--- .../unit/backup/drivers/test_backup_tsm.py | 6 ++-- cinder/tests/unit/backup/fake_swift_client.py | 1 - .../tests/unit/backup/fake_swift_client2.py | 1 - cinder/tests/unit/backup/test_backup.py | 4 +-- .../tests/unit/backup/test_chunkeddriver.py | 2 +- cinder/tests/unit/backup/test_rpcapi.py | 2 +- cinder/tests/unit/brick/test_brick_lvm.py | 4 ++- cinder/tests/unit/cast_as_call.py | 2 +- cinder/tests/unit/cmd/test_status.py | 4 +-- cinder/tests/unit/compute/test_nova.py | 9 ++--- cinder/tests/unit/db/test_cluster.py | 3 +- cinder/tests/unit/db/test_purge.py | 3 +- cinder/tests/unit/fake_notifier.py | 2 +- cinder/tests/unit/group/test_groups_api.py | 2 +- .../tests/unit/group/test_groups_manager.py | 2 +- .../group/test_groups_manager_replication.py | 2 +- .../unit/image/accelerators/test_qat_gzip.py | 2 +- cinder/tests/unit/image/fake.py | 2 +- cinder/tests/unit/image/test_accelerator.py | 2 +- cinder/tests/unit/image/test_cache.py | 4 +-- cinder/tests/unit/image/test_glance.py | 4 +-- cinder/tests/unit/keymgr/test_migration.py | 3 +- cinder/tests/unit/message/test_api.py | 2 +- .../tests/unit/message/test_message_field.py | 2 +- cinder/tests/unit/objects/test_backup.py | 3 +- cinder/tests/unit/objects/test_base.py | 4 +-- cinder/tests/unit/objects/test_cgsnapshot.py | 3 +- cinder/tests/unit/objects/test_cleanable.py | 3 +- .../unit/objects/test_cleanup_request.py | 2 +- cinder/tests/unit/objects/test_cluster.py | 3 +- .../unit/objects/test_consistencygroup.py | 3 +- cinder/tests/unit/objects/test_group.py | 3 +- .../tests/unit/objects/test_group_snapshot.py | 3 +- cinder/tests/unit/objects/test_group_type.py | 3 +- cinder/tests/unit/objects/test_qos.py | 3 +- cinder/tests/unit/objects/test_service.py | 3 +- cinder/tests/unit/objects/test_snapshot.py | 2 +- cinder/tests/unit/objects/test_volume.py | 3 +- .../unit/objects/test_volume_attachment.py | 3 +- cinder/tests/unit/objects/test_volume_type.py | 3 +- cinder/tests/unit/policies/test_base.py | 2 +- cinder/tests/unit/policies/test_volume.py | 3 +- .../unit/policies/test_volume_actions.py | 3 +- .../unit/policies/test_volume_metadata.py | 3 +- .../test_allocated_capacity_weigher.py | 2 +- .../tests/unit/scheduler/test_base_filter.py | 2 +- .../unit/scheduler/test_capacity_weigher.py | 6 ++-- .../unit/scheduler/test_chance_weigher.py | 2 +- .../unit/scheduler/test_filter_scheduler.py | 7 ++-- .../tests/unit/scheduler/test_host_filters.py | 7 ++-- .../tests/unit/scheduler/test_host_manager.py | 8 ++--- cinder/tests/unit/scheduler/test_rpcapi.py | 6 ++-- cinder/tests/unit/scheduler/test_scheduler.py | 7 ++-- .../test_stochastic_weight_handler.py | 7 ++-- .../scheduler/test_volume_number_weigher.py | 2 +- cinder/tests/unit/targets/targets_fixture.py | 2 +- .../unit/targets/test_base_iscsi_driver.py | 3 +- cinder/tests/unit/targets/test_cxt_driver.py | 3 +- cinder/tests/unit/targets/test_iet_driver.py | 3 +- cinder/tests/unit/targets/test_iser_driver.py | 2 +- cinder/tests/unit/targets/test_lio_driver.py | 3 +- .../tests/unit/targets/test_nvmeof_driver.py | 2 +- .../tests/unit/targets/test_nvmet_driver.py | 2 +- cinder/tests/unit/targets/test_scst_driver.py | 2 +- cinder/tests/unit/targets/test_spdknvmf.py | 2 +- cinder/tests/unit/targets/test_tgt_driver.py | 2 +- cinder/tests/unit/test_api_urlmap.py | 2 +- cinder/tests/unit/test_cleanable_manager.py | 2 +- cinder/tests/unit/test_cmd.py | 4 +-- cinder/tests/unit/test_context.py | 3 +- cinder/tests/unit/test_coordination.py | 2 +- cinder/tests/unit/test_db_api.py | 7 ++-- cinder/tests/unit/test_db_worker_api.py | 2 +- cinder/tests/unit/test_exception.py | 3 +- cinder/tests/unit/test_hacking.py | 4 +-- cinder/tests/unit/test_image_utils.py | 2 +- cinder/tests/unit/test_interface.py | 2 +- cinder/tests/unit/test_macrosan_drivers.py | 2 +- cinder/tests/unit/test_manager.py | 3 +- cinder/tests/unit/test_policy.py | 5 ++- cinder/tests/unit/test_qos_specs.py | 8 ++--- cinder/tests/unit/test_quota.py | 2 +- cinder/tests/unit/test_quota_utils.py | 10 +++--- cinder/tests/unit/test_rpc.py | 3 +- cinder/tests/unit/test_service.py | 7 ++-- cinder/tests/unit/test_service_auth.py | 6 ++-- cinder/tests/unit/test_setup_profiler.py | 2 +- cinder/tests/unit/test_ssh_utils.py | 5 +-- cinder/tests/unit/test_test.py | 3 +- cinder/tests/unit/test_utils.py | 3 +- cinder/tests/unit/test_volume_cleanup.py | 3 +- cinder/tests/unit/test_volume_throttling.py | 2 +- cinder/tests/unit/test_volume_transfer.py | 2 +- cinder/tests/unit/test_volume_types.py | 3 +- cinder/tests/unit/test_volume_utils.py | 4 +-- cinder/tests/unit/utils.py | 4 +-- cinder/tests/unit/volume/__init__.py | 2 +- .../dell_emc/powermax/powermax_data.py | 1 + .../powermax/powermax_fake_objects.py | 1 + .../dell_emc/powermax/test_powermax_common.py | 3 +- .../dell_emc/powermax/test_powermax_fc.py | 2 +- .../dell_emc/powermax/test_powermax_iscsi.py | 3 +- .../powermax/test_powermax_masking.py | 2 +- .../powermax/test_powermax_metadata.py | 2 +- .../powermax/test_powermax_provision.py | 3 +- .../powermax/test_powermax_replication.py | 2 +- .../dell_emc/powermax/test_powermax_rest.py | 2 +- .../dell_emc/powermax/test_powermax_utils.py | 2 +- .../volume/drivers/dell_emc/sc/test_fc.py | 2 +- .../volume/drivers/dell_emc/sc/test_sc.py | 5 +-- .../volume/drivers/dell_emc/sc/test_scapi.py | 7 ++-- .../unit/volume/drivers/dell_emc/test_ps.py | 2 +- .../volume/drivers/dell_emc/test_xtremio.py | 2 +- .../drivers/dell_emc/unity/test_adapter.py | 2 +- .../drivers/dell_emc/unity/test_client.py | 2 +- .../drivers/dell_emc/unity/test_driver.py | 3 +- .../dell_emc/unity/test_replication.py | 2 +- .../drivers/dell_emc/unity/test_utils.py | 2 +- .../volume/drivers/dell_emc/vnx/__init__.py | 3 +- .../volume/drivers/dell_emc/vnx/fake_enum.py | 1 + .../volume/drivers/dell_emc/vnx/res_mock.py | 3 +- .../drivers/dell_emc/vnx/test_adapter.py | 2 +- .../drivers/dell_emc/vnx/test_common.py | 2 +- .../drivers/dell_emc/vnx/test_driver.py | 2 +- .../drivers/dell_emc/vnx/test_replication.py | 2 +- .../volume/drivers/dell_emc/vnx/test_utils.py | 2 +- .../unit/volume/drivers/dell_emc/vnx/utils.py | 2 +- .../drivers/dell_emc/vxflexos/__init__.py | 1 + .../volume/drivers/dell_emc/vxflexos/mocks.py | 4 +-- .../dell_emc/vxflexos/test_create_volume.py | 3 +- .../dell_emc/vxflexos/test_get_manageable.py | 2 +- .../drivers/dell_emc/vxflexos/test_groups.py | 3 +- .../vxflexos/test_initialize_connection.py | 2 +- .../test_initialize_connection_snapshot.py | 2 +- .../dell_emc/vxflexos/test_manage_existing.py | 6 ++-- .../drivers/dell_emc/vxflexos/test_misc.py | 5 +-- .../drivers/hpe/fake_hpe_3par_client.py | 3 +- .../drivers/hpe/fake_hpe_lefthand_client.py | 3 +- .../unit/volume/drivers/hpe/test_hpe3par.py | 2 +- .../volume/drivers/hpe/test_hpelefthand.py | 3 +- .../drivers/huawei/test_huawei_drivers.py | 9 ++--- .../unit/volume/drivers/ibm/fake_pyxcli.py | 2 +- .../volume/drivers/ibm/test_ds8k_proxy.py | 6 ++-- .../drivers/ibm/test_ibm_flashsystem.py | 8 ++--- .../drivers/ibm/test_ibm_flashsystem_iscsi.py | 10 +++--- .../volume/drivers/ibm/test_ibm_storage.py | 3 +- .../volume/drivers/ibm/test_storwize_svc.py | 10 +++--- .../unit/volume/drivers/ibm/test_xiv_proxy.py | 5 +-- .../drivers/infortrend/test_infortrend_cli.py | 2 +- .../infortrend/test_infortrend_common.py | 3 +- .../inspur/as13000/test_as13000_driver.py | 6 ++-- .../volume/drivers/inspur/instorage/fakes.py | 5 +-- .../drivers/inspur/instorage/test_common.py | 10 +++--- .../inspur/instorage/test_fc_driver.py | 7 ++-- .../inspur/instorage/test_helper_routines.py | 10 +++--- .../inspur/instorage/test_iscsi_driver.py | 10 +++--- .../inspur/instorage/test_replication.py | 9 ++--- .../unit/volume/drivers/nec/test_volume.py | 5 +-- .../drivers/netapp/dataontap/client/fakes.py | 2 +- .../netapp/dataontap/client/test_api.py | 8 ++--- .../dataontap/client/test_client_base.py | 4 +-- .../dataontap/client/test_client_cmode.py | 4 +-- .../dataontap/performance/test_perf_base.py | 3 +- .../dataontap/performance/test_perf_cmode.py | 3 +- .../netapp/dataontap/test_block_base.py | 6 ++-- .../netapp/dataontap/test_block_cmode.py | 7 ++-- .../drivers/netapp/dataontap/test_nfs_base.py | 6 ++-- .../netapp/dataontap/test_nfs_cmode.py | 6 ++-- .../dataontap/utils/test_capabilities.py | 2 +- .../dataontap/utils/test_data_motion.py | 6 ++-- .../dataontap/utils/test_loopingcalls.py | 3 +- .../netapp/dataontap/utils/test_utils.py | 2 +- .../unit/volume/drivers/netapp/test_utils.py | 4 +-- .../volume/drivers/nexenta/test_nexenta.py | 9 +++-- .../drivers/nexenta/test_nexenta5_iscsi.py | 6 ++-- .../drivers/nexenta/test_nexenta5_jsonrpc.py | 6 ++-- .../drivers/nexenta/test_nexenta5_nfs.py | 6 ++-- .../drivers/solidfire/test_solidfire.py | 4 +-- .../drivers/synology/test_synology_common.py | 2 +- .../drivers/synology/test_synology_iscsi.py | 2 +- .../tests/unit/volume/drivers/test_datera.py | 3 +- .../unit/volume/drivers/test_fujitsu_dx.py | 4 +-- cinder/tests/unit/volume/drivers/test_gpfs.py | 2 +- .../tests/unit/volume/drivers/test_hedvig.py | 2 +- .../unit/volume/drivers/test_infinidat.py | 5 +-- .../unit/volume/drivers/test_kaminario.py | 4 +-- .../unit/volume/drivers/test_linstordrv.py | 2 +- .../unit/volume/drivers/test_lvm_driver.py | 4 +-- cinder/tests/unit/volume/drivers/test_nfs.py | 6 ++-- cinder/tests/unit/volume/drivers/test_pure.py | 4 +-- cinder/tests/unit/volume/drivers/test_qnap.py | 8 ++--- .../tests/unit/volume/drivers/test_quobyte.py | 8 ++--- cinder/tests/unit/volume/drivers/test_rbd.py | 8 ++--- .../unit/volume/drivers/test_remotefs.py | 2 +- cinder/tests/unit/volume/drivers/test_rsd.py | 7 ++-- cinder/tests/unit/volume/drivers/test_san.py | 2 +- .../tests/unit/volume/drivers/test_seagate.py | 15 ++++---- cinder/tests/unit/volume/drivers/test_spdk.py | 2 +- .../unit/volume/drivers/test_storpool.py | 2 +- .../unit/volume/drivers/test_veritas_cnfs.py | 3 +- .../unit/volume/drivers/test_vzstorage.py | 5 ++- .../tests/unit/volume/drivers/test_zadara.py | 3 +- .../veritas_access/test_veritas_iscsi.py | 2 +- .../unit/volume/drivers/vmware/test_fcd.py | 7 ++-- .../drivers/vmware/test_vmware_datastore.py | 6 ++-- .../volume/drivers/vmware/test_vmware_vmdk.py | 6 ++-- .../drivers/vmware/test_vmware_volumeops.py | 7 ++-- .../volume/flows/test_create_volume_flow.py | 7 ++-- .../volume/flows/test_manage_snapshot_flow.py | 3 +- .../volume/flows/test_manage_volume_flow.py | 3 +- .../unit/volume/test_availability_zone.py | 2 +- cinder/tests/unit/volume/test_capabilities.py | 2 +- cinder/tests/unit/volume/test_connection.py | 3 +- cinder/tests/unit/volume/test_driver.py | 4 +-- cinder/tests/unit/volume/test_image.py | 2 +- cinder/tests/unit/volume/test_init_host.py | 3 +- .../tests/unit/volume/test_manage_volume.py | 2 +- .../unit/volume/test_replication_manager.py | 4 +-- cinder/tests/unit/volume/test_rpcapi.py | 9 +++-- cinder/tests/unit/volume/test_snapshot.py | 4 +-- cinder/tests/unit/volume/test_volume.py | 6 ++-- .../tests/unit/volume/test_volume_manager.py | 2 +- .../unit/volume/test_volume_migration.py | 4 +-- .../tests/unit/volume/test_volume_retype.py | 3 +- cinder/tests/unit/windows/test_iscsi.py | 2 +- cinder/tests/unit/windows/test_smbfs.py | 2 +- .../test_brcd_fc_san_lookup_service.py | 2 +- .../test_brcd_fc_zone_client_cli.py | 2 +- .../zonemanager/test_brcd_fc_zone_driver.py | 2 +- .../test_brcd_http_fc_zone_client.py | 5 ++- .../test_cisco_fc_san_lookup_service.py | 2 +- .../test_cisco_fc_zone_client_cli.py | 2 +- .../zonemanager/test_cisco_fc_zone_driver.py | 2 +- .../unit/zonemanager/test_driverutils.py | 4 +-- .../unit/zonemanager/test_fc_zone_manager.py | 2 +- .../unit/zonemanager/test_volume_driver.py | 2 +- cinder/volume/drivers/datera/datera_api2.py | 8 ++--- cinder/volume/drivers/datera/datera_api21.py | 8 ++--- cinder/volume/drivers/datera/datera_common.py | 5 ++- cinder/volume/drivers/datera/datera_iscsi.py | 3 +- .../drivers/dell_emc/powermax/masking.py | 2 +- .../drivers/dell_emc/powermax/metadata.py | 2 +- .../volume/drivers/dell_emc/powermax/rest.py | 1 - .../volume/drivers/dell_emc/powermax/utils.py | 2 +- .../drivers/dell_emc/sc/storagecenter_api.py | 2 +- .../volume/drivers/dell_emc/unity/driver.py | 1 - cinder/volume/drivers/dell_emc/vnx/adapter.py | 2 -- .../volume/drivers/dell_emc/vnx/taskflows.py | 2 -- cinder/volume/drivers/dell_emc/vnx/utils.py | 2 +- cinder/volume/drivers/dell_emc/xtremio.py | 9 +++-- .../fujitsu/eternus_dx/eternus_dx_iscsi.py | 6 ++-- cinder/volume/drivers/hpe/hpe_3par_common.py | 10 +++--- .../volume/drivers/hpe/hpe_lefthand_iscsi.py | 8 ++--- cinder/volume/drivers/huawei/common.py | 2 +- cinder/volume/drivers/huawei/huawei_conf.py | 7 ++-- cinder/volume/drivers/huawei/rest_client.py | 4 +-- .../drivers/ibm/ibm_storage/ds8k_helper.py | 4 +-- .../drivers/ibm/ibm_storage/ds8k_proxy.py | 5 ++- .../ibm/ibm_storage/ds8k_replication.py | 3 +- .../ibm/ibm_storage/ds8k_restclient.py | 6 ++-- .../volume/drivers/ibm/ibm_storage/proxy.py | 2 +- .../drivers/ibm/ibm_storage/xiv_proxy.py | 4 +-- .../ibm/ibm_storage/xiv_replication.py | 3 +- .../ibm/storwize_svc/storwize_svc_common.py | 2 +- .../ibm/storwize_svc/storwize_svc_iscsi.py | 4 +-- cinder/volume/drivers/infinidat.py | 6 ++-- .../inspur/instorage/instorage_iscsi.py | 4 +-- .../drivers/netapp/dataontap/client/api.py | 6 ++-- .../netapp/dataontap/client/client_base.py | 2 -- .../netapp/dataontap/client/client_cmode.py | 4 +-- .../netapp/dataontap/utils/loopingcalls.py | 6 ++-- cinder/volume/drivers/nexenta/iscsi.py | 3 +- cinder/volume/drivers/nexenta/nfs.py | 2 +- cinder/volume/drivers/nexenta/utils.py | 2 +- cinder/volume/drivers/pure.py | 14 ++++---- cinder/volume/drivers/qnap.py | 6 ++-- cinder/volume/drivers/quobyte.py | 2 +- cinder/volume/drivers/rbd.py | 15 ++++---- cinder/volume/drivers/rsd.py | 21 +++++------- cinder/volume/drivers/stx/client.py | 2 +- cinder/volume/drivers/stx/common.py | 6 ++-- cinder/volume/flows/api/create_volume.py | 2 +- cinder/volume/manager.py | 3 +- cinder/volume/volume_utils.py | 4 +-- cinder/wsgi/wsgi.py | 8 ++--- .../brocade/brcd_http_fc_zone_client.py | 4 +-- .../drivers/cisco/cisco_fc_zone_driver.py | 4 +-- lower-constraints.txt | 1 + test-requirements.txt | 2 +- tools/config/generate_cinder_opts.py | 3 +- tox.ini | 4 ++- 378 files changed, 721 insertions(+), 855 deletions(-) diff --git a/cinder/api/common.py b/cinder/api/common.py index 0334223083a..12642944fd9 100644 --- a/cinder/api/common.py +++ b/cinder/api/common.py @@ -13,12 +13,11 @@ # License for the specific language governing permissions and limitations # under the License. - +import enum import json import os import re -import enum from oslo_config import cfg from oslo_log import log as logging from six.moves import urllib diff --git a/cinder/api/contrib/quotas.py b/cinder/api/contrib/quotas.py index 11ed5e9fe0d..aa1efcc31e3 100644 --- a/cinder/api/contrib/quotas.py +++ b/cinder/api/contrib/quotas.py @@ -13,10 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. -import webob - from oslo_log import log as logging from oslo_utils import strutils +import webob from cinder.api import extensions from cinder.api.openstack import wsgi diff --git a/cinder/api/contrib/volume_image_metadata.py b/cinder/api/contrib/volume_image_metadata.py index 2d53a7e4007..2b7026b5ebe 100644 --- a/cinder/api/contrib/volume_image_metadata.py +++ b/cinder/api/contrib/volume_image_metadata.py @@ -13,11 +13,10 @@ # under the License. """The Volume Image Metadata API extension.""" +from oslo_log import log as logging from six.moves import http_client import webob -from oslo_log import log as logging - from cinder.api import common from cinder.api import extensions from cinder.api.openstack import wsgi @@ -29,7 +28,6 @@ from cinder import objects from cinder.policies import volume_metadata as policy from cinder import volume - LOG = logging.getLogger(__name__) diff --git a/cinder/api/openstack/wsgi.py b/cinder/api/openstack/wsgi.py index e5f05089099..59c4bc6fb19 100644 --- a/cinder/api/openstack/wsgi.py +++ b/cinder/api/openstack/wsgi.py @@ -14,13 +14,7 @@ # License for the specific language governing permissions and limitations # under the License. -# TODO(smcginnis) update this once six has support for collections.abc -# (https://github.com/benjaminp/six/pull/241) or clean up once we drop py2.7. -try: - from collections.abc import Callable -except ImportError: - from collections import Callable - +from collections import abc import functools import inspect import math @@ -39,15 +33,12 @@ import webob.exc from cinder.api.openstack import api_version_request as api_version from cinder.api.openstack import versioned_method from cinder import exception - from cinder import i18n i18n.enable_lazy() - from cinder.i18n import _ from cinder import utils from cinder.wsgi import common as wsgi - LOG = logging.getLogger(__name__) SUPPORTED_CONTENT_TYPES = ( @@ -1095,7 +1086,7 @@ class ControllerMetaclass(type): versioned_methods.append(getattr(base, VER_METHOD_ATTR)) for key, value in cls_dict.items(): - if not isinstance(value, Callable): + if not isinstance(value, abc.Callable): continue if getattr(value, 'wsgi_action', None): actions[value.wsgi_action] = key diff --git a/cinder/backup/api.py b/cinder/backup/api.py index 30f897e24b3..81919626a9e 100644 --- a/cinder/backup/api.py +++ b/cinder/backup/api.py @@ -15,18 +15,17 @@ # License for the specific language governing permissions and limitations # under the License. -""" -Handles all requests relating to the volume backups service. -""" +"""Handles all requests relating to the volume backups service.""" from datetime import datetime +import random + from eventlet import greenthread from oslo_config import cfg from oslo_log import log as logging from oslo_utils import excutils from oslo_utils import strutils from pytz import timezone -import random from cinder.backup import rpcapi as backup_rpcapi from cinder.common import constants diff --git a/cinder/cmd/api.py b/cinder/cmd/api.py index f238a6c35e5..d06c1e30984 100644 --- a/cinder/cmd/api.py +++ b/cinder/cmd/api.py @@ -17,31 +17,27 @@ """Starter script for Cinder OS API.""" -import eventlet -eventlet.monkey_patch() - import logging as python_logging import sys -from cinder import objects - +import eventlet # noqa +eventlet.monkey_patch() from oslo_config import cfg from oslo_log import log as logging from oslo_reports import guru_meditation_report as gmr from oslo_reports import opts as gmr_opts -from cinder import i18n +from cinder import i18n # noqa i18n.enable_lazy() - # Need to register global_opts from cinder.common import config from cinder import coordination +from cinder import objects from cinder import rpc from cinder import service from cinder import utils from cinder import version - CONF = cfg.CONF diff --git a/cinder/cmd/backup.py b/cinder/cmd/backup.py index d0fdc4c30d3..30e1fbe6c7b 100644 --- a/cinder/cmd/backup.py +++ b/cinder/cmd/backup.py @@ -26,7 +26,6 @@ import sys # share the same context. import eventlet eventlet.monkey_patch() - from oslo_concurrency import processutils from oslo_config import cfg from oslo_log import log as logging @@ -34,13 +33,11 @@ from oslo_privsep import priv_context from oslo_reports import guru_meditation_report as gmr from oslo_reports import opts as gmr_opts - -from cinder import i18n -i18n.enable_lazy() - # Need to register global_opts from cinder.common import config # noqa from cinder.db import api as session +from cinder import i18n +i18n.enable_lazy() from cinder import objects from cinder import service from cinder import utils diff --git a/cinder/cmd/scheduler.py b/cinder/cmd/scheduler.py index 3b3c1033268..9420a01995b 100644 --- a/cinder/cmd/scheduler.py +++ b/cinder/cmd/scheduler.py @@ -17,22 +17,20 @@ """Starter script for Cinder Scheduler.""" -import eventlet -eventlet.monkey_patch() - import logging as python_logging import sys +import eventlet +eventlet.monkey_patch() from oslo_config import cfg from oslo_log import log as logging from oslo_reports import guru_meditation_report as gmr from oslo_reports import opts as gmr_opts -from cinder import i18n -i18n.enable_lazy() - # Need to register global_opts from cinder.common import config # noqa +from cinder import i18n +i18n.enable_lazy() from cinder import objects from cinder import service from cinder import utils diff --git a/cinder/cmd/status.py b/cinder/cmd/status.py index 9b77313e757..b91481e31ba 100644 --- a/cinder/cmd/status.py +++ b/cinder/cmd/status.py @@ -18,21 +18,19 @@ import os import sys +from oslo_config import cfg +from oslo_upgradecheck import upgradecheck as uc + from cinder import context from cinder import db from cinder import exception from cinder import objects -from cinder import service # noqa -from oslo_config import cfg -from oslo_upgradecheck import upgradecheck as uc - from cinder.policy import DEFAULT_POLICY_FILENAME -import cinder.service # noqa - +# Need to import service to load config +from cinder import service # noqa # We must first register Cinder's objects. Otherwise # we cannot import the volume manager. objects.register_all() - import cinder.volume.manager as volume_manager CONF = cfg.CONF diff --git a/cinder/cmd/volume.py b/cinder/cmd/volume.py index 4cc7cca561b..d31fb0d78dd 100644 --- a/cinder/cmd/volume.py +++ b/cinder/cmd/volume.py @@ -16,11 +16,14 @@ # under the License. """Starter script for Cinder Volume.""" +import logging as python_logging +import os +import re +import shlex +import sys import eventlet import eventlet.tpool -import os - # Monkey patching must go before the oslo.log import, otherwise # oslo.context will not use greenthread thread local and all greenthreads # will share the same context. @@ -30,36 +33,25 @@ if os.name == 'nt': eventlet.monkey_patch(os=False) else: eventlet.monkey_patch() - -import logging as python_logging -import re - -from cinder import exception -from cinder import objects - - -import shlex -import sys - from oslo_config import cfg from oslo_log import log as logging from oslo_privsep import priv_context from oslo_reports import guru_meditation_report as gmr from oslo_reports import opts as gmr_opts -from cinder import i18n -i18n.enable_lazy() - # Need to register global_opts from cinder.common import config # noqa from cinder.common import constants from cinder.db import api as session +from cinder import exception +from cinder import i18n +i18n.enable_lazy() from cinder.i18n import _ +from cinder import objects from cinder import service from cinder import utils from cinder import version - CONF = cfg.CONF host_opt = cfg.StrOpt('backend_host', help='Backend override of host value.') diff --git a/cinder/cmd/volume_usage_audit.py b/cinder/cmd/volume_usage_audit.py index 7c3dce53d22..598aaecb829 100644 --- a/cinder/cmd/volume_usage_audit.py +++ b/cinder/cmd/volume_usage_audit.py @@ -15,35 +15,35 @@ # under the License. """ - Cron script to generate usage notifications for volumes existing during - the audit period. +Cron script to generate usage notifications for volumes existing during +the audit period. - Together with the notifications generated by volumes - create/delete/resize, over that time period, this allows an external - system consuming usage notification feeds to calculate volume usage - for each tenant. +Together with the notifications generated by volumes +create/delete/resize, over that time period, this allows an external +system consuming usage notification feeds to calculate volume usage +for each tenant. - Time periods are specified as 'hour', 'month', 'day' or 'year' +Time periods are specified as 'hour', 'month', 'day' or 'year' - - `hour` - previous hour. If run at 9:07am, will generate usage for - 8-9am. - - `month` - previous month. If the script is run April 1, it will - generate usages for March 1 through March 31. - - `day` - previous day. if run on July 4th, it generates usages for - July 3rd. - - `year` - previous year. If run on Jan 1, it generates usages for - Jan 1 through Dec 31 of the previous year. +- `hour` - previous hour. If run at 9:07am, will generate usage for + 8-9am. +- `month` - previous month. If the script is run April 1, it will + generate usages for March 1 through March 31. +- `day` - previous day. if run on July 4th, it generates usages for + July 3rd. +- `year` - previous year. If run on Jan 1, it generates usages for + Jan 1 through Dec 31 of the previous year. """ import datetime -import iso8601 import sys +import iso8601 from oslo_config import cfg from oslo_log import log as logging -from cinder import i18n +from cinder import i18n # noqa i18n.enable_lazy() from cinder import context from cinder.i18n import _ diff --git a/cinder/db/sqlalchemy/api.py b/cinder/db/sqlalchemy/api.py index c74fe513502..0d4eac93b4f 100644 --- a/cinder/db/sqlalchemy/api.py +++ b/cinder/db/sqlalchemy/api.py @@ -18,14 +18,8 @@ """Implementation of SQLAlchemy backend.""" - import collections - -try: - from collections.abc import Iterable -except ImportError: - from collections import Iterable - +from collections import abc import datetime as dt import functools import itertools @@ -7135,7 +7129,7 @@ def condition_db_filter(model, field, value): """ orm_field = getattr(model, field) # For values that must match and are iterables we use IN - if (isinstance(value, Iterable) and + if (isinstance(value, abc.Iterable) and not isinstance(value, six.string_types)): # We cannot use in_ when one of the values is None if None not in value: @@ -7161,7 +7155,7 @@ def condition_not_db_filter(model, field, value, auto_none=True): result = ~condition_db_filter(model, field, value) if (auto_none - and ((isinstance(value, Iterable) and + and ((isinstance(value, abc.Iterable) and not isinstance(value, six.string_types) and None not in value) or (value is not None))): diff --git a/cinder/db/sqlalchemy/migrate_repo/manage.py b/cinder/db/sqlalchemy/migrate_repo/manage.py index 22877d94003..1314740829f 100644 --- a/cinder/db/sqlalchemy/migrate_repo/manage.py +++ b/cinder/db/sqlalchemy/migrate_repo/manage.py @@ -15,10 +15,10 @@ import os -from cinder.db.sqlalchemy import migrate_repo - from migrate.versioning.shell import main +from cinder.db.sqlalchemy import migrate_repo + if __name__ == '__main__': main(debug='False', diff --git a/cinder/image/cache.py b/cinder/image/cache.py index 9a72f95ff82..164a4e4515c 100644 --- a/cinder/image/cache.py +++ b/cinder/image/cache.py @@ -12,12 +12,11 @@ # License for the specific language governing permissions and limitations # under the License. -from pytz import timezone -import six - from oslo_config import cfg from oslo_log import log as logging from oslo_utils import timeutils +from pytz import timezone +import six from cinder import objects from cinder import rpc diff --git a/cinder/keymgr/migration.py b/cinder/keymgr/migration.py index e7721bea99e..49be70ada30 100644 --- a/cinder/keymgr/migration.py +++ b/cinder/keymgr/migration.py @@ -16,13 +16,12 @@ import binascii import itertools -from oslo_config import cfg -from oslo_log import log as logging - from barbicanclient import client as barbican_client from castellan import options as castellan_options from keystoneauth1 import loading as ks_loading from keystoneauth1 import session as ks_session +from oslo_config import cfg +from oslo_log import log as logging from cinder import context from cinder import coordination diff --git a/cinder/manager.py b/cinder/manager.py index e478c0b438b..269ca0a001c 100644 --- a/cinder/manager.py +++ b/cinder/manager.py @@ -51,7 +51,8 @@ This module provides Manager, a base class for managers. """ - +from eventlet import greenpool +from eventlet import tpool from oslo_config import cfg from oslo_log import log as logging import oslo_messaging as messaging @@ -67,10 +68,6 @@ from cinder import rpc from cinder.scheduler import rpcapi as scheduler_rpcapi from cinder import utils -from eventlet import greenpool -from eventlet import tpool - - CONF = cfg.CONF LOG = logging.getLogger(__name__) diff --git a/cinder/objects/cgsnapshot.py b/cinder/objects/cgsnapshot.py index fc48aba289d..99b83996e61 100644 --- a/cinder/objects/cgsnapshot.py +++ b/cinder/objects/cgsnapshot.py @@ -12,12 +12,13 @@ # License for the specific language governing permissions and limitations # under the License. +from oslo_versionedobjects import fields + from cinder import db from cinder import exception from cinder.i18n import _ from cinder import objects from cinder.objects import base -from oslo_versionedobjects import fields @base.CinderObjectRegistry.register diff --git a/cinder/objects/consistencygroup.py b/cinder/objects/consistencygroup.py index 05979cd6561..e216d4233fc 100644 --- a/cinder/objects/consistencygroup.py +++ b/cinder/objects/consistencygroup.py @@ -13,6 +13,7 @@ # under the License. from oslo_utils import versionutils +from oslo_versionedobjects import fields from cinder import db from cinder import exception @@ -20,7 +21,6 @@ from cinder.i18n import _ from cinder import objects from cinder.objects import base from cinder.objects import fields as c_fields -from oslo_versionedobjects import fields @base.CinderObjectRegistry.register diff --git a/cinder/objects/group_snapshot.py b/cinder/objects/group_snapshot.py index 9baca5b4aee..5021fd5e87d 100644 --- a/cinder/objects/group_snapshot.py +++ b/cinder/objects/group_snapshot.py @@ -12,12 +12,13 @@ # License for the specific language governing permissions and limitations # under the License. +from oslo_versionedobjects import fields + from cinder import db from cinder import exception from cinder.i18n import _ from cinder import objects from cinder.objects import base -from oslo_versionedobjects import fields @base.CinderObjectRegistry.register diff --git a/cinder/objects/qos_specs.py b/cinder/objects/qos_specs.py index fb82a527b27..6fdfe1a4bde 100644 --- a/cinder/objects/qos_specs.py +++ b/cinder/objects/qos_specs.py @@ -12,6 +12,7 @@ from oslo_db import exception as db_exc from oslo_log import log as logging +from oslo_versionedobjects import fields from cinder import db from cinder import exception @@ -19,7 +20,6 @@ from cinder.i18n import _ from cinder import objects from cinder.objects import base from cinder.objects import fields as c_fields -from oslo_versionedobjects import fields LOG = logging.getLogger(__name__) diff --git a/cinder/opts.py b/cinder/opts.py index 31c22291338..8db24f8d11b 100644 --- a/cinder/opts.py +++ b/cinder/opts.py @@ -25,9 +25,8 @@ import itertools from keystoneauth1 import loading -from cinder import objects +from cinder import objects # noqa objects.register_all() - from cinder.api import common as cinder_api_common from cinder.api.middleware import auth as cinder_api_middleware_auth from cinder.api.views import versions as cinder_api_views_versions diff --git a/cinder/quota_utils.py b/cinder/quota_utils.py index 3bccd129e81..f047306ac01 100644 --- a/cinder/quota_utils.py +++ b/cinder/quota_utils.py @@ -12,13 +12,12 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -from oslo_config import cfg -from oslo_log import log as logging - from keystoneauth1 import identity from keystoneauth1 import loading as ka_loading from keystoneclient import client from keystoneclient import exceptions +from oslo_config import cfg +from oslo_log import log as logging from cinder import db from cinder import exception diff --git a/cinder/test.py b/cinder/test.py index cbdeff5b10e..99fdeb57bdf 100644 --- a/cinder/test.py +++ b/cinder/test.py @@ -24,12 +24,12 @@ import copy import logging import os import sys +from unittest import mock import uuid from eventlet import tpool import fixtures from keystonemiddleware import auth_token -import mock from oslo_concurrency import lockutils from oslo_config import fixture as config_fixture from oslo_log.fixture import logging_error as log_fixture @@ -58,7 +58,6 @@ from cinder.tests.unit import fake_notifier from cinder.volume import volume_types from cinder.volume import volume_utils - CONF = config.CONF _DB_CACHE = None diff --git a/cinder/tests/functional/functional_helpers.py b/cinder/tests/functional/functional_helpers.py index 8bcfffa224a..b229cb927d7 100644 --- a/cinder/tests/functional/functional_helpers.py +++ b/cinder/tests/functional/functional_helpers.py @@ -13,17 +13,15 @@ # License for the specific language governing permissions and limitations # under the License. -""" -Provides common functionality for functional tests -""" +"""Provides common functionality for functional tests.""" import os.path import random import string import time +from unittest import mock import uuid import fixtures -import mock from oslo_config import cfg from cinder import service diff --git a/cinder/tests/functional/test_quotas.py b/cinder/tests/functional/test_quotas.py index e7231e33836..4a367c5e522 100644 --- a/cinder/tests/functional/test_quotas.py +++ b/cinder/tests/functional/test_quotas.py @@ -11,7 +11,7 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock import uuid from cinder import quota diff --git a/cinder/tests/hacking/checks.py b/cinder/tests/hacking/checks.py index d8026e7b361..5caa6574a56 100644 --- a/cinder/tests/hacking/checks.py +++ b/cinder/tests/hacking/checks.py @@ -14,6 +14,7 @@ import ast import re + import six """ diff --git a/cinder/tests/unit/api/contrib/test_admin_actions.py b/cinder/tests/unit/api/contrib/test_admin_actions.py index e692ee1d032..b827e76cce8 100644 --- a/cinder/tests/unit/api/contrib/test_admin_actions.py +++ b/cinder/tests/unit/api/contrib/test_admin_actions.py @@ -10,9 +10,10 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt import fixtures -import mock from oslo_concurrency import lockutils from oslo_config import fixture as config_fixture import oslo_messaging as messaging diff --git a/cinder/tests/unit/api/contrib/test_backup_project_attribute.py b/cinder/tests/unit/api/contrib/test_backup_project_attribute.py index b3c1974a0b3..dcd48f70260 100644 --- a/cinder/tests/unit/api/contrib/test_backup_project_attribute.py +++ b/cinder/tests/unit/api/contrib/test_backup_project_attribute.py @@ -13,7 +13,6 @@ # under the License. import ddt - from oslo_serialization import jsonutils import webob diff --git a/cinder/tests/unit/api/contrib/test_backups.py b/cinder/tests/unit/api/contrib/test_backups.py index 97d3b29dd54..c9a0280499e 100644 --- a/cinder/tests/unit/api/contrib/test_backups.py +++ b/cinder/tests/unit/api/contrib/test_backups.py @@ -13,12 +13,11 @@ # License for the specific language governing permissions and limitations # under the License. -""" -Tests for Backup code. -""" +"""Tests for Backup code.""" + +from unittest import mock import ddt -import mock from oslo_serialization import jsonutils from oslo_utils import timeutils import six diff --git a/cinder/tests/unit/api/contrib/test_capabilities.py b/cinder/tests/unit/api/contrib/test_capabilities.py index 4c92598afdd..af5922b496f 100644 --- a/cinder/tests/unit/api/contrib/test_capabilities.py +++ b/cinder/tests/unit/api/contrib/test_capabilities.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock import oslo_messaging diff --git a/cinder/tests/unit/api/contrib/test_cgsnapshots.py b/cinder/tests/unit/api/contrib/test_cgsnapshots.py index 1fe0b1f899a..a88be6d3b59 100644 --- a/cinder/tests/unit/api/contrib/test_cgsnapshots.py +++ b/cinder/tests/unit/api/contrib/test_cgsnapshots.py @@ -13,11 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. -""" -Tests for cgsnapshot code. -""" +"""Tests for cgsnapshot code.""" + +from unittest import mock -import mock from oslo_serialization import jsonutils from six.moves import http_client import webob @@ -30,7 +29,6 @@ from cinder import objects from cinder import test from cinder.tests.unit.api import fakes from cinder.tests.unit import fake_constants as fake - from cinder.tests.unit import utils import cinder.volume diff --git a/cinder/tests/unit/api/contrib/test_consistencygroups.py b/cinder/tests/unit/api/contrib/test_consistencygroups.py index 1e40b915a11..1bdad409560 100644 --- a/cinder/tests/unit/api/contrib/test_consistencygroups.py +++ b/cinder/tests/unit/api/contrib/test_consistencygroups.py @@ -13,12 +13,11 @@ # License for the specific language governing permissions and limitations # under the License. -""" -Tests for consistency group code. -""" +"""Tests for consistency group code.""" + +from unittest import mock import ddt -import mock from oslo_serialization import jsonutils from six.moves import http_client import webob diff --git a/cinder/tests/unit/api/contrib/test_extended_snapshot_attributes.py b/cinder/tests/unit/api/contrib/test_extended_snapshot_attributes.py index 87f7707b4ff..f93ab118aec 100644 --- a/cinder/tests/unit/api/contrib/test_extended_snapshot_attributes.py +++ b/cinder/tests/unit/api/contrib/test_extended_snapshot_attributes.py @@ -13,8 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock -import mock from oslo_serialization import jsonutils from six.moves import http_client import webob diff --git a/cinder/tests/unit/api/contrib/test_hosts.py b/cinder/tests/unit/api/contrib/test_hosts.py index f4d2a849a79..cfdf5048963 100644 --- a/cinder/tests/unit/api/contrib/test_hosts.py +++ b/cinder/tests/unit/api/contrib/test_hosts.py @@ -14,7 +14,7 @@ # under the License. import datetime -import mock +from unittest import mock import iso8601 from oslo_utils import timeutils diff --git a/cinder/tests/unit/api/contrib/test_qos_specs_manage.py b/cinder/tests/unit/api/contrib/test_qos_specs_manage.py index d12fd41bc8e..ec111154c3c 100644 --- a/cinder/tests/unit/api/contrib/test_qos_specs_manage.py +++ b/cinder/tests/unit/api/contrib/test_qos_specs_manage.py @@ -14,8 +14,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from six.moves import http_client import webob diff --git a/cinder/tests/unit/api/contrib/test_quotas.py b/cinder/tests/unit/api/contrib/test_quotas.py index 51b8cb3357b..dcf122c8865 100644 --- a/cinder/tests/unit/api/contrib/test_quotas.py +++ b/cinder/tests/unit/api/contrib/test_quotas.py @@ -14,14 +14,14 @@ # License for the specific language governing permissions and limitations # under the License. -""" -Tests for cinder.api.contrib.quotas.py -""" +"""Tests for cinder.api.contrib.quotas.py""" +from unittest import mock +import uuid import ddt -import mock -import uuid +from oslo_config import cfg +from oslo_config import fixture as config_fixture import webob.exc from cinder.api.contrib import quotas @@ -34,10 +34,6 @@ from cinder.tests.unit import fake_constants as fake from cinder.tests.unit import test_db_api -from oslo_config import cfg -from oslo_config import fixture as config_fixture - - CONF = cfg.CONF diff --git a/cinder/tests/unit/api/contrib/test_quotas_classes.py b/cinder/tests/unit/api/contrib/test_quotas_classes.py index 9e1b8a98942..b84b1c1341e 100644 --- a/cinder/tests/unit/api/contrib/test_quotas_classes.py +++ b/cinder/tests/unit/api/contrib/test_quotas_classes.py @@ -18,7 +18,7 @@ Tests for cinder.api.contrib.quota_classes.py """ -import mock +from unittest import mock from cinder.api.contrib import quota_classes from cinder import context diff --git a/cinder/tests/unit/api/contrib/test_scheduler_stats.py b/cinder/tests/unit/api/contrib/test_scheduler_stats.py index d0262eb2668..bc501f3fe40 100644 --- a/cinder/tests/unit/api/contrib/test_scheduler_stats.py +++ b/cinder/tests/unit/api/contrib/test_scheduler_stats.py @@ -14,8 +14,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock import webob from cinder.api.contrib import scheduler_stats diff --git a/cinder/tests/unit/api/contrib/test_services.py b/cinder/tests/unit/api/contrib/test_services.py index a6e5135c533..c369bc27c37 100644 --- a/cinder/tests/unit/api/contrib/test_services.py +++ b/cinder/tests/unit/api/contrib/test_services.py @@ -13,12 +13,11 @@ # License for the specific language governing permissions and limitations # under the License. - import datetime +from unittest import mock import ddt import iso8601 -import mock from oslo_config import cfg from six.moves import http_client diff --git a/cinder/tests/unit/api/contrib/test_snapshot_actions.py b/cinder/tests/unit/api/contrib/test_snapshot_actions.py index 1efa89f56e2..d127d9d55d2 100644 --- a/cinder/tests/unit/api/contrib/test_snapshot_actions.py +++ b/cinder/tests/unit/api/contrib/test_snapshot_actions.py @@ -12,8 +12,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from oslo_serialization import jsonutils from six.moves import http_client import webob diff --git a/cinder/tests/unit/api/contrib/test_snapshot_manage.py b/cinder/tests/unit/api/contrib/test_snapshot_manage.py index ee79624810f..b423d568bc9 100644 --- a/cinder/tests/unit/api/contrib/test_snapshot_manage.py +++ b/cinder/tests/unit/api/contrib/test_snapshot_manage.py @@ -13,7 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from oslo_config import cfg import oslo_messaging as messaging from oslo_serialization import jsonutils diff --git a/cinder/tests/unit/api/contrib/test_snapshot_unmanage.py b/cinder/tests/unit/api/contrib/test_snapshot_unmanage.py index 24e79b2a0c7..ecfdb662c14 100644 --- a/cinder/tests/unit/api/contrib/test_snapshot_unmanage.py +++ b/cinder/tests/unit/api/contrib/test_snapshot_unmanage.py @@ -12,7 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from oslo_serialization import jsonutils from six.moves import http_client import webob diff --git a/cinder/tests/unit/api/contrib/test_types_extra_specs.py b/cinder/tests/unit/api/contrib/test_types_extra_specs.py index a636dd4a4f8..34ad5583568 100644 --- a/cinder/tests/unit/api/contrib/test_types_extra_specs.py +++ b/cinder/tests/unit/api/contrib/test_types_extra_specs.py @@ -15,8 +15,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from oslo_config import cfg from oslo_utils import timeutils import webob diff --git a/cinder/tests/unit/api/contrib/test_types_manage.py b/cinder/tests/unit/api/contrib/test_types_manage.py index aee6397cd5b..9769c2b0826 100644 --- a/cinder/tests/unit/api/contrib/test_types_manage.py +++ b/cinder/tests/unit/api/contrib/test_types_manage.py @@ -13,12 +13,12 @@ # License for the specific language governing permissions and limitations # under the License. -import mock -import six -import webob +from unittest import mock import ddt from oslo_utils import strutils +import six +import webob from cinder.api.contrib import types_manage from cinder import context diff --git a/cinder/tests/unit/api/contrib/test_used_limits.py b/cinder/tests/unit/api/contrib/test_used_limits.py index 15d40eb41b9..446e609af53 100644 --- a/cinder/tests/unit/api/contrib/test_used_limits.py +++ b/cinder/tests/unit/api/contrib/test_used_limits.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from cinder.api.contrib import used_limits from cinder.api import microversions as mv diff --git a/cinder/tests/unit/api/contrib/test_volume_actions.py b/cinder/tests/unit/api/contrib/test_volume_actions.py index e1146441f23..5651152c868 100644 --- a/cinder/tests/unit/api/contrib/test_volume_actions.py +++ b/cinder/tests/unit/api/contrib/test_volume_actions.py @@ -13,10 +13,10 @@ # under the License. import datetime +from unittest import mock import uuid import ddt -import mock from oslo_config import cfg import oslo_messaging as messaging from oslo_serialization import jsonutils diff --git a/cinder/tests/unit/api/contrib/test_volume_image_metadata.py b/cinder/tests/unit/api/contrib/test_volume_image_metadata.py index 674ee4d9f05..35184297a2b 100644 --- a/cinder/tests/unit/api/contrib/test_volume_image_metadata.py +++ b/cinder/tests/unit/api/contrib/test_volume_image_metadata.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock import uuid from oslo_policy import policy as oslo_policy diff --git a/cinder/tests/unit/api/contrib/test_volume_manage.py b/cinder/tests/unit/api/contrib/test_volume_manage.py index ca5935a9b75..174aa85117e 100644 --- a/cinder/tests/unit/api/contrib/test_volume_manage.py +++ b/cinder/tests/unit/api/contrib/test_volume_manage.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from oslo_config import cfg import oslo_messaging as messaging from oslo_serialization import jsonutils diff --git a/cinder/tests/unit/api/contrib/test_volume_transfer.py b/cinder/tests/unit/api/contrib/test_volume_transfer.py index 137fbdd0672..951d8f49c14 100644 --- a/cinder/tests/unit/api/contrib/test_volume_transfer.py +++ b/cinder/tests/unit/api/contrib/test_volume_transfer.py @@ -13,11 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. -""" -Tests for volume transfer code. -""" +"""Tests for volume transfer code.""" + +from unittest import mock -import mock from oslo_serialization import jsonutils from six.moves import http_client import webob diff --git a/cinder/tests/unit/api/contrib/test_volume_type_access.py b/cinder/tests/unit/api/contrib/test_volume_type_access.py index cb03a624722..c184130c300 100644 --- a/cinder/tests/unit/api/contrib/test_volume_type_access.py +++ b/cinder/tests/unit/api/contrib/test_volume_type_access.py @@ -12,7 +12,7 @@ # under the License. import datetime -import mock +from unittest import mock from six.moves import http_client import webob diff --git a/cinder/tests/unit/api/contrib/test_volume_unmanage.py b/cinder/tests/unit/api/contrib/test_volume_unmanage.py index 8ef6ecb7395..a011d02b8a2 100644 --- a/cinder/tests/unit/api/contrib/test_volume_unmanage.py +++ b/cinder/tests/unit/api/contrib/test_volume_unmanage.py @@ -12,7 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from oslo_serialization import jsonutils from six.moves import http_client import webob diff --git a/cinder/tests/unit/api/openstack/test_wsgi.py b/cinder/tests/unit/api/openstack/test_wsgi.py index 570f75838a3..3a5a3e72a62 100644 --- a/cinder/tests/unit/api/openstack/test_wsgi.py +++ b/cinder/tests/unit/api/openstack/test_wsgi.py @@ -10,10 +10,10 @@ # License for the specific language governing permissions and limitations # under the License. -import ddt import inspect +from unittest import mock -import mock +import ddt from oslo_utils import encodeutils from six.moves import http_client import webob diff --git a/cinder/tests/unit/api/test_common.py b/cinder/tests/unit/api/test_common.py index c169e27ad3d..e563df89180 100644 --- a/cinder/tests/unit/api/test_common.py +++ b/cinder/tests/unit/api/test_common.py @@ -14,18 +14,16 @@ # License for the specific language governing permissions and limitations # under the License. -""" -Test suites for 'common' code used throughout the OpenStack HTTP API. -""" +"""Test suites for 'common' code used throughout the OpenStack HTTP API.""" + +from unittest import mock import ddt -import mock +from oslo_config import cfg from testtools import matchers import webob import webob.exc -from oslo_config import cfg - from cinder.api import common from cinder import test diff --git a/cinder/tests/unit/api/v2/fakes.py b/cinder/tests/unit/api/v2/fakes.py index 132516dc0c5..f3248420c15 100644 --- a/cinder/tests/unit/api/v2/fakes.py +++ b/cinder/tests/unit/api/v2/fakes.py @@ -14,6 +14,7 @@ # under the License. import datetime + import iso8601 from cinder import exception as exc diff --git a/cinder/tests/unit/api/v2/test_snapshot_metadata.py b/cinder/tests/unit/api/v2/test_snapshot_metadata.py index acc01c25283..7d777ff5b76 100644 --- a/cinder/tests/unit/api/v2/test_snapshot_metadata.py +++ b/cinder/tests/unit/api/v2/test_snapshot_metadata.py @@ -13,10 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock import uuid import ddt -import mock from oslo_serialization import jsonutils from six.moves import http_client import webob diff --git a/cinder/tests/unit/api/v2/test_snapshots.py b/cinder/tests/unit/api/v2/test_snapshots.py index 1abbbce1895..2737fdd90ba 100644 --- a/cinder/tests/unit/api/v2/test_snapshots.py +++ b/cinder/tests/unit/api/v2/test_snapshots.py @@ -14,8 +14,9 @@ # under the License. import datetime +from unittest import mock + import ddt -import mock from oslo_config import cfg import pytz from six.moves import http_client diff --git a/cinder/tests/unit/api/v2/test_types.py b/cinder/tests/unit/api/v2/test_types.py index 63b2383043b..e0219392a24 100644 --- a/cinder/tests/unit/api/v2/test_types.py +++ b/cinder/tests/unit/api/v2/test_types.py @@ -13,9 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock import uuid -import mock from oslo_utils import timeutils import six import webob diff --git a/cinder/tests/unit/api/v2/test_volume_metadata.py b/cinder/tests/unit/api/v2/test_volume_metadata.py index cc38f973f26..0dbc04093d1 100644 --- a/cinder/tests/unit/api/v2/test_volume_metadata.py +++ b/cinder/tests/unit/api/v2/test_volume_metadata.py @@ -13,9 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock import uuid -import mock from oslo_config import cfg from oslo_serialization import jsonutils from six.moves import http_client diff --git a/cinder/tests/unit/api/v2/test_volumes.py b/cinder/tests/unit/api/v2/test_volumes.py index b6c001a7672..1d9de12572f 100644 --- a/cinder/tests/unit/api/v2/test_volumes.py +++ b/cinder/tests/unit/api/v2/test_volumes.py @@ -15,12 +15,12 @@ import datetime -import iso8601 import json +from unittest import mock import ddt import fixtures -import mock +import iso8601 from oslo_config import cfg import six from six.moves import http_client diff --git a/cinder/tests/unit/api/v3/fakes.py b/cinder/tests/unit/api/v3/fakes.py index a8e81f34e56..7b931fb7035 100644 --- a/cinder/tests/unit/api/v3/fakes.py +++ b/cinder/tests/unit/api/v3/fakes.py @@ -11,6 +11,7 @@ # under the License. import datetime + import iso8601 from cinder.tests.unit import fake_constants as fake diff --git a/cinder/tests/unit/api/v3/stubs.py b/cinder/tests/unit/api/v3/stubs.py index c167b256dd1..1903637f634 100644 --- a/cinder/tests/unit/api/v3/stubs.py +++ b/cinder/tests/unit/api/v3/stubs.py @@ -11,6 +11,7 @@ # under the License. import datetime + import iso8601 from cinder.tests.unit import fake_constants as fake diff --git a/cinder/tests/unit/api/v3/test_attachments.py b/cinder/tests/unit/api/v3/test_attachments.py index 324c4089eec..32d70737b4f 100644 --- a/cinder/tests/unit/api/v3/test_attachments.py +++ b/cinder/tests/unit/api/v3/test_attachments.py @@ -13,12 +13,11 @@ # License for the specific language governing permissions and limitations # under the License. -""" -Tests for attachments Api. -""" +"""Tests for attachments Api.""" + +from unittest import mock import ddt -import mock from oslo_policy import policy as oslo_policy from cinder.api import microversions as mv diff --git a/cinder/tests/unit/api/v3/test_backups.py b/cinder/tests/unit/api/v3/test_backups.py index acf55a7c0fa..faa8cb5e989 100644 --- a/cinder/tests/unit/api/v3/test_backups.py +++ b/cinder/tests/unit/api/v3/test_backups.py @@ -16,8 +16,9 @@ """The backups V3 api.""" import copy +from unittest import mock + import ddt -import mock from oslo_serialization import jsonutils from oslo_utils import strutils import webob diff --git a/cinder/tests/unit/api/v3/test_cluster.py b/cinder/tests/unit/api/v3/test_cluster.py index c1bec721ef1..60484d4df30 100644 --- a/cinder/tests/unit/api/v3/test_cluster.py +++ b/cinder/tests/unit/api/v3/test_cluster.py @@ -14,10 +14,10 @@ # under the License. import datetime +from unittest import mock import ddt import iso8601 -import mock from oslo_utils import versionutils from cinder.api import extensions diff --git a/cinder/tests/unit/api/v3/test_group_snapshots.py b/cinder/tests/unit/api/v3/test_group_snapshots.py index 5b5ad5665c2..12ecfcc9267 100644 --- a/cinder/tests/unit/api/v3/test_group_snapshots.py +++ b/cinder/tests/unit/api/v3/test_group_snapshots.py @@ -13,12 +13,11 @@ # License for the specific language governing permissions and limitations # under the License. -""" -Tests for group_snapshot code. -""" +"""Tests for group_snapshot code.""" + +from unittest import mock import ddt -import mock from oslo_policy import policy as oslo_policy from six.moves import http_client import webob diff --git a/cinder/tests/unit/api/v3/test_group_specs.py b/cinder/tests/unit/api/v3/test_group_specs.py index 87247ed59bb..248692ce25e 100644 --- a/cinder/tests/unit/api/v3/test_group_specs.py +++ b/cinder/tests/unit/api/v3/test_group_specs.py @@ -13,17 +13,17 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + import webob +from cinder.api import microversions as mv +from cinder.api.v3 import group_specs as v3_group_specs from cinder import context from cinder import db from cinder import exception from cinder import rpc from cinder import test - -from cinder.api import microversions as mv -from cinder.api.v3 import group_specs as v3_group_specs from cinder.tests.unit.api import fakes from cinder.tests.unit import fake_constants as fake diff --git a/cinder/tests/unit/api/v3/test_group_types.py b/cinder/tests/unit/api/v3/test_group_types.py index 9f6d7d25c25..749bef0e914 100644 --- a/cinder/tests/unit/api/v3/test_group_types.py +++ b/cinder/tests/unit/api/v3/test_group_types.py @@ -13,10 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock import uuid import ddt -import mock from oslo_utils import strutils from oslo_utils import timeutils import six diff --git a/cinder/tests/unit/api/v3/test_groups.py b/cinder/tests/unit/api/v3/test_groups.py index 21dc8628555..7423b4e7c4d 100644 --- a/cinder/tests/unit/api/v3/test_groups.py +++ b/cinder/tests/unit/api/v3/test_groups.py @@ -13,12 +13,11 @@ # License for the specific language governing permissions and limitations # under the License. -""" -Tests for group code. -""" +"""Tests for group code.""" + +from unittest import mock import ddt -import mock from six.moves import http_client import webob diff --git a/cinder/tests/unit/api/v3/test_limits.py b/cinder/tests/unit/api/v3/test_limits.py index 7e9694fe7f0..1776f263777 100644 --- a/cinder/tests/unit/api/v3/test_limits.py +++ b/cinder/tests/unit/api/v3/test_limits.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from cinder.api import microversions as mv from cinder.api.openstack import api_version_request as api_version diff --git a/cinder/tests/unit/api/v3/test_messages.py b/cinder/tests/unit/api/v3/test_messages.py index bb6bce435c0..5d427d2233d 100644 --- a/cinder/tests/unit/api/v3/test_messages.py +++ b/cinder/tests/unit/api/v3/test_messages.py @@ -10,8 +10,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from six.moves import http_client from cinder.api import extensions diff --git a/cinder/tests/unit/api/v3/test_resource_filters.py b/cinder/tests/unit/api/v3/test_resource_filters.py index f348cbbcbc4..57c35620815 100644 --- a/cinder/tests/unit/api/v3/test_resource_filters.py +++ b/cinder/tests/unit/api/v3/test_resource_filters.py @@ -10,12 +10,11 @@ # License for the specific language governing permissions and limitations # under the License. -""" -Tests for resource filters API. -""" +"""Tests for resource filters API.""" + +from unittest import mock import ddt -import mock import six from cinder.api import microversions as mv diff --git a/cinder/tests/unit/api/v3/test_snapshot_manage.py b/cinder/tests/unit/api/v3/test_snapshot_manage.py index cba769648c0..a64238992e9 100644 --- a/cinder/tests/unit/api/v3/test_snapshot_manage.py +++ b/cinder/tests/unit/api/v3/test_snapshot_manage.py @@ -12,8 +12,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from oslo_config import cfg from oslo_serialization import jsonutils from six.moves import http_client diff --git a/cinder/tests/unit/api/v3/test_snapshots.py b/cinder/tests/unit/api/v3/test_snapshots.py index d5eeede0874..7a1342d71a3 100644 --- a/cinder/tests/unit/api/v3/test_snapshots.py +++ b/cinder/tests/unit/api/v3/test_snapshots.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from oslo_utils import strutils from cinder.api import microversions as mv diff --git a/cinder/tests/unit/api/v3/test_volume_manage.py b/cinder/tests/unit/api/v3/test_volume_manage.py index 8d1ca65bc60..ae7c112a403 100644 --- a/cinder/tests/unit/api/v3/test_volume_manage.py +++ b/cinder/tests/unit/api/v3/test_volume_manage.py @@ -12,8 +12,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from oslo_config import cfg from oslo_serialization import jsonutils from six.moves import http_client diff --git a/cinder/tests/unit/api/v3/test_volume_metadata.py b/cinder/tests/unit/api/v3/test_volume_metadata.py index 97431d4e63f..5f7a93b4d63 100644 --- a/cinder/tests/unit/api/v3/test_volume_metadata.py +++ b/cinder/tests/unit/api/v3/test_volume_metadata.py @@ -10,9 +10,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock import uuid -import mock from oslo_config import cfg from oslo_serialization import jsonutils diff --git a/cinder/tests/unit/api/v3/test_volume_transfer.py b/cinder/tests/unit/api/v3/test_volume_transfer.py index d521f5f8d92..9922e75c70b 100644 --- a/cinder/tests/unit/api/v3/test_volume_transfer.py +++ b/cinder/tests/unit/api/v3/test_volume_transfer.py @@ -13,12 +13,11 @@ # License for the specific language governing permissions and limitations # under the License. -""" -Tests for volume transfer code. -""" -import ddt +"""Tests for volume transfer code.""" -import mock +from unittest import mock + +import ddt from oslo_serialization import jsonutils from six.moves import http_client import webob diff --git a/cinder/tests/unit/api/v3/test_volumes.py b/cinder/tests/unit/api/v3/test_volumes.py index 26e5a606fca..2197503aa46 100644 --- a/cinder/tests/unit/api/v3/test_volumes.py +++ b/cinder/tests/unit/api/v3/test_volumes.py @@ -12,12 +12,12 @@ # under the License. import datetime -import ddt -import iso8601 import json +from unittest import mock +import ddt import fixtures -import mock +import iso8601 from oslo_serialization import jsonutils from oslo_utils import strutils from six.moves import http_client diff --git a/cinder/tests/unit/api/v3/test_workers.py b/cinder/tests/unit/api/v3/test_workers.py index b3cabfd1492..ad52a74d684 100644 --- a/cinder/tests/unit/api/v3/test_workers.py +++ b/cinder/tests/unit/api/v3/test_workers.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from oslo_serialization import jsonutils from six.moves import http_client import webob diff --git a/cinder/tests/unit/attachments/test_attachments_api.py b/cinder/tests/unit/attachments/test_attachments_api.py index 8b50b072a37..7d8a48ceb12 100644 --- a/cinder/tests/unit/attachments/test_attachments_api.py +++ b/cinder/tests/unit/attachments/test_attachments_api.py @@ -10,7 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from oslo_config import cfg from oslo_policy import policy as oslo_policy diff --git a/cinder/tests/unit/attachments/test_attachments_manager.py b/cinder/tests/unit/attachments/test_attachments_manager.py index 3b62d3d0854..6e72af2dea5 100644 --- a/cinder/tests/unit/attachments/test_attachments_manager.py +++ b/cinder/tests/unit/attachments/test_attachments_manager.py @@ -10,7 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from oslo_config import cfg from oslo_utils import importutils diff --git a/cinder/tests/unit/backup/drivers/test_backup_ceph.py b/cinder/tests/unit/backup/drivers/test_backup_ceph.py index 19d90eb9266..0aac7598937 100644 --- a/cinder/tests/unit/backup/drivers/test_backup_ceph.py +++ b/cinder/tests/unit/backup/drivers/test_backup_ceph.py @@ -19,10 +19,10 @@ import json import os import tempfile import threading +from unittest import mock import uuid import ddt -import mock from os_brick.initiator import linuxrbd from oslo_concurrency import processutils from oslo_config import cfg diff --git a/cinder/tests/unit/backup/drivers/test_backup_driver_base.py b/cinder/tests/unit/backup/drivers/test_backup_driver_base.py index 5caa5bfa7f1..8aa6b5cd0e9 100644 --- a/cinder/tests/unit/backup/drivers/test_backup_driver_base.py +++ b/cinder/tests/unit/backup/drivers/test_backup_driver_base.py @@ -14,9 +14,9 @@ # under the License. """ Tests for the backup service base driver. """ +from unittest import mock import uuid -import mock from oslo_serialization import jsonutils from cinder.backup import driver diff --git a/cinder/tests/unit/backup/drivers/test_backup_glusterfs.py b/cinder/tests/unit/backup/drivers/test_backup_glusterfs.py index 64061c583f2..706f2e17d5f 100644 --- a/cinder/tests/unit/backup/drivers/test_backup_glusterfs.py +++ b/cinder/tests/unit/backup/drivers/test_backup_glusterfs.py @@ -12,13 +12,10 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -""" -Tests for GlusterFS backup driver. - -""" +"""Tests for GlusterFS backup driver.""" import os +from unittest import mock -import mock from os_brick.remotefs import remotefs as remotefs_brick from cinder.backup.drivers import glusterfs diff --git a/cinder/tests/unit/backup/drivers/test_backup_google.py b/cinder/tests/unit/backup/drivers/test_backup_google.py index b0af9381863..34dbbbd5f9d 100644 --- a/cinder/tests/unit/backup/drivers/test_backup_google.py +++ b/cinder/tests/unit/backup/drivers/test_backup_google.py @@ -14,10 +14,7 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -""" -Tests for Google Backup code. - -""" +"""Tests for Google Backup code.""" import bz2 import filecmp @@ -26,10 +23,10 @@ import os import shutil import tempfile import threading +from unittest import mock import zlib from eventlet import tpool -import mock from oslo_utils import units from cinder.backup.drivers import gcs as google_dr diff --git a/cinder/tests/unit/backup/drivers/test_backup_nfs.py b/cinder/tests/unit/backup/drivers/test_backup_nfs.py index 6c03e877f88..83c933ef684 100644 --- a/cinder/tests/unit/backup/drivers/test_backup_nfs.py +++ b/cinder/tests/unit/backup/drivers/test_backup_nfs.py @@ -12,12 +12,9 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -""" -Tests for Backup NFS driver. +"""Tests for Backup NFS driver.""" -""" import bz2 -import ddt import filecmp import hashlib import os @@ -25,10 +22,11 @@ import shutil import stat import tempfile import threading +from unittest import mock import zlib +import ddt from eventlet import tpool -import mock from os_brick import exception as brick_exception from os_brick.remotefs import remotefs as remotefs_brick from oslo_config import cfg diff --git a/cinder/tests/unit/backup/drivers/test_backup_posix.py b/cinder/tests/unit/backup/drivers/test_backup_posix.py index 35ba51ad82e..3945012a1b7 100644 --- a/cinder/tests/unit/backup/drivers/test_backup_posix.py +++ b/cinder/tests/unit/backup/drivers/test_backup_posix.py @@ -12,14 +12,11 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -""" -Tests for Posix backup driver. - -""" +"""Tests for Posix backup driver.""" import os +from unittest import mock -import mock from six.moves import builtins from cinder.backup.drivers import posix diff --git a/cinder/tests/unit/backup/drivers/test_backup_swift.py b/cinder/tests/unit/backup/drivers/test_backup_swift.py index 9c6963aaf12..5ea7c264c88 100644 --- a/cinder/tests/unit/backup/drivers/test_backup_swift.py +++ b/cinder/tests/unit/backup/drivers/test_backup_swift.py @@ -12,23 +12,20 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -""" -Tests for Backup swift code. - -""" +"""Tests for Backup swift code.""" import bz2 -import ddt import filecmp import hashlib import os import shutil import tempfile import threading +from unittest import mock import zlib +import ddt from eventlet import tpool -import mock from oslo_config import cfg from swiftclient import client as swift diff --git a/cinder/tests/unit/backup/drivers/test_backup_tsm.py b/cinder/tests/unit/backup/drivers/test_backup_tsm.py index 953506f9c7c..6dbb95c41aa 100644 --- a/cinder/tests/unit/backup/drivers/test_backup_tsm.py +++ b/cinder/tests/unit/backup/drivers/test_backup_tsm.py @@ -13,13 +13,11 @@ # License for the specific language governing permissions and limitations # under the License. # -""" -Tests for volume backup to IBM Tivoli Storage Manager (TSM). -""" +"""Tests for volume backup to IBM Tivoli Storage Manager (TSM).""" import json -import mock import posix +from unittest import mock from oslo_concurrency import processutils as putils from oslo_utils import timeutils diff --git a/cinder/tests/unit/backup/fake_swift_client.py b/cinder/tests/unit/backup/fake_swift_client.py index b56ff889126..cc988773b5f 100644 --- a/cinder/tests/unit/backup/fake_swift_client.py +++ b/cinder/tests/unit/backup/fake_swift_client.py @@ -20,7 +20,6 @@ import zlib import six from six.moves import http_client - from swiftclient import client as swift diff --git a/cinder/tests/unit/backup/fake_swift_client2.py b/cinder/tests/unit/backup/fake_swift_client2.py index 312d2174320..efb1d0a8dea 100644 --- a/cinder/tests/unit/backup/fake_swift_client2.py +++ b/cinder/tests/unit/backup/fake_swift_client2.py @@ -20,7 +20,6 @@ import socket import tempfile from six.moves import http_client - from swiftclient import client as swift diff --git a/cinder/tests/unit/backup/test_backup.py b/cinder/tests/unit/backup/test_backup.py index abe3308fa45..3fc7c875cad 100644 --- a/cinder/tests/unit/backup/test_backup.py +++ b/cinder/tests/unit/backup/test_backup.py @@ -15,12 +15,12 @@ """Tests for Backup code.""" import copy -import ddt import os +from unittest import mock import uuid +import ddt from eventlet import tpool -import mock from os_brick.initiator.connectors import fake as fake_connectors from oslo_config import cfg from oslo_db import exception as db_exc diff --git a/cinder/tests/unit/backup/test_chunkeddriver.py b/cinder/tests/unit/backup/test_chunkeddriver.py index 73222c1f3ea..8e1558fa05b 100644 --- a/cinder/tests/unit/backup/test_chunkeddriver.py +++ b/cinder/tests/unit/backup/test_chunkeddriver.py @@ -14,9 +14,9 @@ """Tests for the base chunkedbackupdriver class.""" import json +from unittest import mock import uuid -import mock from oslo_config import cfg from oslo_utils import units diff --git a/cinder/tests/unit/backup/test_rpcapi.py b/cinder/tests/unit/backup/test_rpcapi.py index e61bdd48927..8b7c578b4bb 100644 --- a/cinder/tests/unit/backup/test_rpcapi.py +++ b/cinder/tests/unit/backup/test_rpcapi.py @@ -16,7 +16,7 @@ Unit Tests for cinder.backup.rpcapi """ -import mock +from unittest import mock from cinder.backup import rpcapi as backup_rpcapi from cinder import objects diff --git a/cinder/tests/unit/brick/test_brick_lvm.py b/cinder/tests/unit/brick/test_brick_lvm.py index 3a9f1d0f7ae..1cf7582039b 100644 --- a/cinder/tests/unit/brick/test_brick_lvm.py +++ b/cinder/tests/unit/brick/test_brick_lvm.py @@ -12,8 +12,10 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. + +from unittest import mock + import ddt -import mock from oslo_concurrency import processutils from cinder.brick.local_dev import lvm as brick diff --git a/cinder/tests/unit/cast_as_call.py b/cinder/tests/unit/cast_as_call.py index caf47d4421c..03dea361df8 100644 --- a/cinder/tests/unit/cast_as_call.py +++ b/cinder/tests/unit/cast_as_call.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock def mock_cast_as_call(obj=None): diff --git a/cinder/tests/unit/cmd/test_status.py b/cinder/tests/unit/cmd/test_status.py index 70ec3b8f75f..20074538cf2 100644 --- a/cinder/tests/unit/cmd/test_status.py +++ b/cinder/tests/unit/cmd/test_status.py @@ -12,10 +12,10 @@ """Unit tests for the cinder-status CLI interfaces.""" -import ddt -import mock +from unittest import mock import uuid +import ddt from oslo_config import cfg from oslo_upgradecheck import upgradecheck as uc import testtools diff --git a/cinder/tests/unit/compute/test_nova.py b/cinder/tests/unit/compute/test_nova.py index 03b31cdb470..4a748d0b861 100644 --- a/cinder/tests/unit/compute/test_nova.py +++ b/cinder/tests/unit/compute/test_nova.py @@ -12,17 +12,18 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt from keystoneauth1 import exceptions as ks_exc -import mock +from keystoneauth1 import loading as ks_loading +from novaclient import exceptions as nova_exceptions +from oslo_config import cfg from cinder.compute import nova from cinder import context from cinder.message import message_field from cinder import test -from keystoneauth1 import loading as ks_loading -from novaclient import exceptions as nova_exceptions -from oslo_config import cfg CONF = cfg.CONF diff --git a/cinder/tests/unit/db/test_cluster.py b/cinder/tests/unit/db/test_cluster.py index 5350da36a99..cab32cd8982 100644 --- a/cinder/tests/unit/db/test_cluster.py +++ b/cinder/tests/unit/db/test_cluster.py @@ -15,7 +15,8 @@ """Tests for cluster table related operations.""" -import mock +from unittest import mock + from oslo_config import cfg from sqlalchemy.orm import exc diff --git a/cinder/tests/unit/db/test_purge.py b/cinder/tests/unit/db/test_purge.py index 7d3f005fbb8..f7526036aad 100644 --- a/cinder/tests/unit/db/test_purge.py +++ b/cinder/tests/unit/db/test_purge.py @@ -19,6 +19,7 @@ import datetime import uuid from oslo_db import exception as db_exc +from oslo_db.sqlalchemy import utils as sqlalchemyutils from oslo_utils import timeutils from sqlalchemy.dialects import sqlite @@ -28,8 +29,6 @@ from cinder.db.sqlalchemy import api as db_api from cinder import exception from cinder import test -from oslo_db.sqlalchemy import utils as sqlalchemyutils - class PurgeDeletedTest(test.TestCase): diff --git a/cinder/tests/unit/fake_notifier.py b/cinder/tests/unit/fake_notifier.py index 7e07a263b6c..2f9b1509ce8 100644 --- a/cinder/tests/unit/fake_notifier.py +++ b/cinder/tests/unit/fake_notifier.py @@ -14,8 +14,8 @@ import collections import functools - import json + import oslo_messaging as messaging from cinder import rpc diff --git a/cinder/tests/unit/group/test_groups_api.py b/cinder/tests/unit/group/test_groups_api.py index 394cb23fa12..5fed1b1a439 100644 --- a/cinder/tests/unit/group/test_groups_api.py +++ b/cinder/tests/unit/group/test_groups_api.py @@ -16,9 +16,9 @@ """ Tests for group API. """ +from unittest import mock import ddt -import mock from cinder import context from cinder import exception diff --git a/cinder/tests/unit/group/test_groups_manager.py b/cinder/tests/unit/group/test_groups_manager.py index f68f976a2c7..855c28618e9 100644 --- a/cinder/tests/unit/group/test_groups_manager.py +++ b/cinder/tests/unit/group/test_groups_manager.py @@ -12,9 +12,9 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +from unittest import mock import ddt -import mock from oslo_config import cfg from oslo_utils import importutils diff --git a/cinder/tests/unit/group/test_groups_manager_replication.py b/cinder/tests/unit/group/test_groups_manager_replication.py index 1942ef3a64a..fd2337aeb8a 100644 --- a/cinder/tests/unit/group/test_groups_manager_replication.py +++ b/cinder/tests/unit/group/test_groups_manager_replication.py @@ -12,9 +12,9 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +from unittest import mock import ddt -import mock from oslo_config import cfg from oslo_utils import importutils diff --git a/cinder/tests/unit/image/accelerators/test_qat_gzip.py b/cinder/tests/unit/image/accelerators/test_qat_gzip.py index 3fa87a94e85..8c745421fa8 100644 --- a/cinder/tests/unit/image/accelerators/test_qat_gzip.py +++ b/cinder/tests/unit/image/accelerators/test_qat_gzip.py @@ -11,7 +11,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from cinder import exception from cinder.image import accelerator diff --git a/cinder/tests/unit/image/fake.py b/cinder/tests/unit/image/fake.py index e76469399bd..53c7b9c317e 100644 --- a/cinder/tests/unit/image/fake.py +++ b/cinder/tests/unit/image/fake.py @@ -18,7 +18,7 @@ import copy import datetime -import mock +from unittest import mock import uuid from cinder import exception diff --git a/cinder/tests/unit/image/test_accelerator.py b/cinder/tests/unit/image/test_accelerator.py index 4f7466c7b76..ce7a0dbe0c1 100644 --- a/cinder/tests/unit/image/test_accelerator.py +++ b/cinder/tests/unit/image/test_accelerator.py @@ -12,7 +12,7 @@ # under the License. -import mock +from unittest import mock from cinder.image import accelerator from cinder import test diff --git a/cinder/tests/unit/image/test_cache.py b/cinder/tests/unit/image/test_cache.py index 1b23a58ce58..f630de785f6 100644 --- a/cinder/tests/unit/image/test_cache.py +++ b/cinder/tests/unit/image/test_cache.py @@ -13,9 +13,9 @@ # under the License. from datetime import timedelta -import ddt -import mock +from unittest import mock +import ddt from oslo_utils import timeutils from cinder import context as ctxt diff --git a/cinder/tests/unit/image/test_glance.py b/cinder/tests/unit/image/test_glance.py index 7c87791619d..c2d1b911553 100644 --- a/cinder/tests/unit/image/test_glance.py +++ b/cinder/tests/unit/image/test_glance.py @@ -16,14 +16,14 @@ import datetime import itertools -import six +from unittest import mock import ddt import glanceclient.exc from keystoneauth1.loading import session as ks_session from keystoneauth1 import session -import mock from oslo_config import cfg +import six from cinder import context from cinder import exception diff --git a/cinder/tests/unit/keymgr/test_migration.py b/cinder/tests/unit/keymgr/test_migration.py index 1272a0df08d..311251530bf 100644 --- a/cinder/tests/unit/keymgr/test_migration.py +++ b/cinder/tests/unit/keymgr/test_migration.py @@ -14,7 +14,8 @@ # under the License. """Tests for encryption key migration.""" -import mock +from unittest import mock + from oslo_config import cfg from cinder import db diff --git a/cinder/tests/unit/message/test_api.py b/cinder/tests/unit/message/test_api.py index c300873f8f1..7d1c38ecc0b 100644 --- a/cinder/tests/unit/message/test_api.py +++ b/cinder/tests/unit/message/test_api.py @@ -10,8 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. import datetime +from unittest import mock -import mock from oslo_config import cfg from oslo_utils import timeutils diff --git a/cinder/tests/unit/message/test_message_field.py b/cinder/tests/unit/message/test_message_field.py index 4611bb0b437..772f9e7afb3 100644 --- a/cinder/tests/unit/message/test_message_field.py +++ b/cinder/tests/unit/message/test_message_field.py @@ -10,10 +10,10 @@ # License for the specific language governing permissions and limitations # under the License. -import ddt import inspect from itertools import chain +import ddt from oslo_config import cfg from cinder import exception diff --git a/cinder/tests/unit/objects/test_backup.py b/cinder/tests/unit/objects/test_backup.py index 9f4e9027fd5..60f5c67adfc 100644 --- a/cinder/tests/unit/objects/test_backup.py +++ b/cinder/tests/unit/objects/test_backup.py @@ -12,7 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from oslo_utils import timeutils import pytz import six diff --git a/cinder/tests/unit/objects/test_base.py b/cinder/tests/unit/objects/test_base.py index e38b2925eb0..2353fef2a01 100644 --- a/cinder/tests/unit/objects/test_base.py +++ b/cinder/tests/unit/objects/test_base.py @@ -13,11 +13,11 @@ # under the License. import datetime -import ddt +from unittest import mock import uuid +import ddt from iso8601 import iso8601 -import mock from oslo_versionedobjects import fields from sqlalchemy import sql diff --git a/cinder/tests/unit/objects/test_cgsnapshot.py b/cinder/tests/unit/objects/test_cgsnapshot.py index 42696122bf3..f1bbdca6aef 100644 --- a/cinder/tests/unit/objects/test_cgsnapshot.py +++ b/cinder/tests/unit/objects/test_cgsnapshot.py @@ -12,7 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from oslo_utils import timeutils import pytz import six diff --git a/cinder/tests/unit/objects/test_cleanable.py b/cinder/tests/unit/objects/test_cleanable.py index 7830f39023e..26202b33024 100644 --- a/cinder/tests/unit/objects/test_cleanable.py +++ b/cinder/tests/unit/objects/test_cleanable.py @@ -14,8 +14,7 @@ # under the License. import inspect - -import mock +from unittest import mock from cinder import context from cinder import exception diff --git a/cinder/tests/unit/objects/test_cleanup_request.py b/cinder/tests/unit/objects/test_cleanup_request.py index 5ec6d65c93b..8f81d572523 100644 --- a/cinder/tests/unit/objects/test_cleanup_request.py +++ b/cinder/tests/unit/objects/test_cleanup_request.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from oslo_utils import timeutils diff --git a/cinder/tests/unit/objects/test_cluster.py b/cinder/tests/unit/objects/test_cluster.py index bc41df7358b..6f56bfa5929 100644 --- a/cinder/tests/unit/objects/test_cluster.py +++ b/cinder/tests/unit/objects/test_cluster.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from oslo_utils import timeutils import cinder.db diff --git a/cinder/tests/unit/objects/test_consistencygroup.py b/cinder/tests/unit/objects/test_consistencygroup.py index e27d66fa610..b50f46d530d 100644 --- a/cinder/tests/unit/objects/test_consistencygroup.py +++ b/cinder/tests/unit/objects/test_consistencygroup.py @@ -12,7 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from oslo_utils import timeutils import pytz import six diff --git a/cinder/tests/unit/objects/test_group.py b/cinder/tests/unit/objects/test_group.py index f2f00a5cd05..255c1b34ef9 100644 --- a/cinder/tests/unit/objects/test_group.py +++ b/cinder/tests/unit/objects/test_group.py @@ -12,8 +12,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock import six from cinder import exception diff --git a/cinder/tests/unit/objects/test_group_snapshot.py b/cinder/tests/unit/objects/test_group_snapshot.py index b51924f5a90..c8d580e7fa3 100644 --- a/cinder/tests/unit/objects/test_group_snapshot.py +++ b/cinder/tests/unit/objects/test_group_snapshot.py @@ -12,7 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from oslo_utils import timeutils import pytz import six diff --git a/cinder/tests/unit/objects/test_group_type.py b/cinder/tests/unit/objects/test_group_type.py index 71c1877e91f..0381f239a96 100644 --- a/cinder/tests/unit/objects/test_group_type.py +++ b/cinder/tests/unit/objects/test_group_type.py @@ -12,7 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + import six from cinder import objects diff --git a/cinder/tests/unit/objects/test_qos.py b/cinder/tests/unit/objects/test_qos.py index 8f900d24d41..ff39bd6747c 100644 --- a/cinder/tests/unit/objects/test_qos.py +++ b/cinder/tests/unit/objects/test_qos.py @@ -10,7 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from oslo_utils import timeutils import pytz diff --git a/cinder/tests/unit/objects/test_service.py b/cinder/tests/unit/objects/test_service.py index 67289818312..dc39984ff17 100644 --- a/cinder/tests/unit/objects/test_service.py +++ b/cinder/tests/unit/objects/test_service.py @@ -13,8 +13,9 @@ # under the License. import datetime +from unittest import mock + import ddt -import mock from oslo_utils import timeutils import pytz import six diff --git a/cinder/tests/unit/objects/test_snapshot.py b/cinder/tests/unit/objects/test_snapshot.py index e091bc3ce80..fc3f8fda374 100644 --- a/cinder/tests/unit/objects/test_snapshot.py +++ b/cinder/tests/unit/objects/test_snapshot.py @@ -13,9 +13,9 @@ # under the License. import copy +from unittest import mock import ddt -import mock from oslo_utils import timeutils import pytz import six diff --git a/cinder/tests/unit/objects/test_volume.py b/cinder/tests/unit/objects/test_volume.py index 59f9bb02a52..fe2581df771 100644 --- a/cinder/tests/unit/objects/test_volume.py +++ b/cinder/tests/unit/objects/test_volume.py @@ -12,8 +12,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from oslo_utils import timeutils import pytz import six diff --git a/cinder/tests/unit/objects/test_volume_attachment.py b/cinder/tests/unit/objects/test_volume_attachment.py index 1eba69af841..d44e6ac407a 100644 --- a/cinder/tests/unit/objects/test_volume_attachment.py +++ b/cinder/tests/unit/objects/test_volume_attachment.py @@ -12,8 +12,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock import six from sqlalchemy.orm import attributes diff --git a/cinder/tests/unit/objects/test_volume_type.py b/cinder/tests/unit/objects/test_volume_type.py index 6267ac1bd54..1074447eacd 100644 --- a/cinder/tests/unit/objects/test_volume_type.py +++ b/cinder/tests/unit/objects/test_volume_type.py @@ -12,8 +12,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from oslo_utils import timeutils import pytz import six diff --git a/cinder/tests/unit/policies/test_base.py b/cinder/tests/unit/policies/test_base.py index 1c6bd726de3..eeec19e9ac1 100644 --- a/cinder/tests/unit/policies/test_base.py +++ b/cinder/tests/unit/policies/test_base.py @@ -12,9 +12,9 @@ # under the License. import uuid -import webob from oslo_serialization import jsonutils +import webob from cinder.api import microversions as mv from cinder import context as cinder_context diff --git a/cinder/tests/unit/policies/test_volume.py b/cinder/tests/unit/policies/test_volume.py index d52024c8e05..efc99e92673 100644 --- a/cinder/tests/unit/policies/test_volume.py +++ b/cinder/tests/unit/policies/test_volume.py @@ -11,7 +11,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from six.moves import http_client from cinder.tests.unit import fake_constants diff --git a/cinder/tests/unit/policies/test_volume_actions.py b/cinder/tests/unit/policies/test_volume_actions.py index 69267d0afdd..bb8c7138a0f 100644 --- a/cinder/tests/unit/policies/test_volume_actions.py +++ b/cinder/tests/unit/policies/test_volume_actions.py @@ -11,7 +11,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from six.moves import http_client from cinder.api import microversions as mv diff --git a/cinder/tests/unit/policies/test_volume_metadata.py b/cinder/tests/unit/policies/test_volume_metadata.py index e7e6d156094..fc0d9930352 100644 --- a/cinder/tests/unit/policies/test_volume_metadata.py +++ b/cinder/tests/unit/policies/test_volume_metadata.py @@ -11,7 +11,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from six.moves import http_client from cinder.tests.unit.policies import test_base diff --git a/cinder/tests/unit/scheduler/test_allocated_capacity_weigher.py b/cinder/tests/unit/scheduler/test_allocated_capacity_weigher.py index d871a8dde50..744aef80acf 100644 --- a/cinder/tests/unit/scheduler/test_allocated_capacity_weigher.py +++ b/cinder/tests/unit/scheduler/test_allocated_capacity_weigher.py @@ -17,7 +17,7 @@ Tests For Allocated Capacity Weigher. """ -import mock +from unittest import mock from cinder.common import constants from cinder import context diff --git a/cinder/tests/unit/scheduler/test_base_filter.py b/cinder/tests/unit/scheduler/test_base_filter.py index cf950b464be..04e05738b86 100644 --- a/cinder/tests/unit/scheduler/test_base_filter.py +++ b/cinder/tests/unit/scheduler/test_base_filter.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock +from unittest import mock from cinder.scheduler import base_filter from cinder import test diff --git a/cinder/tests/unit/scheduler/test_capacity_weigher.py b/cinder/tests/unit/scheduler/test_capacity_weigher.py index 6cc8c394d66..4fc06e6bb92 100644 --- a/cinder/tests/unit/scheduler/test_capacity_weigher.py +++ b/cinder/tests/unit/scheduler/test_capacity_weigher.py @@ -12,13 +12,11 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -""" -Tests For Capacity Weigher. -""" +"""Tests For Capacity Weigher.""" from datetime import datetime +from unittest import mock import ddt -import mock from cinder.common import constants from cinder import context diff --git a/cinder/tests/unit/scheduler/test_chance_weigher.py b/cinder/tests/unit/scheduler/test_chance_weigher.py index e99c42d130f..3db6f45ca2b 100644 --- a/cinder/tests/unit/scheduler/test_chance_weigher.py +++ b/cinder/tests/unit/scheduler/test_chance_weigher.py @@ -15,7 +15,7 @@ Tests For Chance Weigher. """ -import mock +from unittest import mock from cinder.scheduler import host_manager from cinder.scheduler.weights import chance diff --git a/cinder/tests/unit/scheduler/test_filter_scheduler.py b/cinder/tests/unit/scheduler/test_filter_scheduler.py index d836c6377e0..142872ba787 100644 --- a/cinder/tests/unit/scheduler/test_filter_scheduler.py +++ b/cinder/tests/unit/scheduler/test_filter_scheduler.py @@ -12,12 +12,11 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -""" -Tests For Filter Scheduler. -""" +"""Tests For Filter Scheduler.""" + +from unittest import mock import ddt -import mock from cinder import context from cinder import exception diff --git a/cinder/tests/unit/scheduler/test_host_filters.py b/cinder/tests/unit/scheduler/test_host_filters.py index 8ffc113f31e..82d8a37acf8 100644 --- a/cinder/tests/unit/scheduler/test_host_filters.py +++ b/cinder/tests/unit/scheduler/test_host_filters.py @@ -11,12 +11,11 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -""" -Tests For Scheduler Host Filters. -""" +"""Tests For Scheduler Host Filters.""" + +from unittest import mock import ddt -import mock from oslo_serialization import jsonutils from requests import exceptions as request_exceptions diff --git a/cinder/tests/unit/scheduler/test_host_manager.py b/cinder/tests/unit/scheduler/test_host_manager.py index 37c198b663d..3218f1f3d30 100644 --- a/cinder/tests/unit/scheduler/test_host_manager.py +++ b/cinder/tests/unit/scheduler/test_host_manager.py @@ -12,15 +12,13 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -""" -Tests For HostManager -""" +"""Tests For HostManager.""" from datetime import datetime from datetime import timedelta -import ddt +from unittest import mock -import mock +import ddt from oslo_serialization import jsonutils from oslo_utils import timeutils diff --git a/cinder/tests/unit/scheduler/test_rpcapi.py b/cinder/tests/unit/scheduler/test_rpcapi.py index 72294ec4f0c..dc75d2e3ef4 100644 --- a/cinder/tests/unit/scheduler/test_rpcapi.py +++ b/cinder/tests/unit/scheduler/test_rpcapi.py @@ -13,14 +13,12 @@ # License for the specific language governing permissions and limitations # under the License. -""" -Unit Tests for cinder.scheduler.rpcapi -""" +"""Unit Tests for cinder.scheduler.rpcapi.""" from datetime import datetime +from unittest import mock import ddt -import mock from cinder import exception from cinder import objects diff --git a/cinder/tests/unit/scheduler/test_scheduler.py b/cinder/tests/unit/scheduler/test_scheduler.py index 5bc18e48463..5603ecdd7de 100644 --- a/cinder/tests/unit/scheduler/test_scheduler.py +++ b/cinder/tests/unit/scheduler/test_scheduler.py @@ -13,15 +13,14 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -""" -Tests For Scheduler -""" +"""Tests For Scheduler.""" import collections import copy from datetime import datetime +from unittest import mock + import ddt -import mock from oslo_config import cfg from cinder.common import constants diff --git a/cinder/tests/unit/scheduler/test_stochastic_weight_handler.py b/cinder/tests/unit/scheduler/test_stochastic_weight_handler.py index 9cd7e786afc..082b3e4d3d0 100644 --- a/cinder/tests/unit/scheduler/test_stochastic_weight_handler.py +++ b/cinder/tests/unit/scheduler/test_stochastic_weight_handler.py @@ -10,12 +10,11 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -""" -Tests for stochastic weight handler -""" +"""Tests for stochastic weight handler.""" + +import random import ddt -import random from cinder.scheduler import base_weight from cinder.scheduler.weights.stochastic import StochasticHostWeightHandler diff --git a/cinder/tests/unit/scheduler/test_volume_number_weigher.py b/cinder/tests/unit/scheduler/test_volume_number_weigher.py index 890571af233..7029ad38589 100644 --- a/cinder/tests/unit/scheduler/test_volume_number_weigher.py +++ b/cinder/tests/unit/scheduler/test_volume_number_weigher.py @@ -16,7 +16,7 @@ Tests For Volume Number Weigher. """ -import mock +from unittest import mock from cinder.common import constants from cinder import context diff --git a/cinder/tests/unit/targets/targets_fixture.py b/cinder/tests/unit/targets/targets_fixture.py index d8b9bf7fdc7..4f4ffa02ac9 100644 --- a/cinder/tests/unit/targets/targets_fixture.py +++ b/cinder/tests/unit/targets/targets_fixture.py @@ -14,8 +14,8 @@ import copy import os import shutil import tempfile +from unittest import mock -import mock from oslo_utils import fileutils from oslo_utils import timeutils diff --git a/cinder/tests/unit/targets/test_base_iscsi_driver.py b/cinder/tests/unit/targets/test_base_iscsi_driver.py index 0fdcb4e9893..4536b302840 100644 --- a/cinder/tests/unit/targets/test_base_iscsi_driver.py +++ b/cinder/tests/unit/targets/test_base_iscsi_driver.py @@ -10,7 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from oslo_config import cfg from cinder import context diff --git a/cinder/tests/unit/targets/test_cxt_driver.py b/cinder/tests/unit/targets/test_cxt_driver.py index c1a7d62ff4c..adcbe7447bf 100644 --- a/cinder/tests/unit/targets/test_cxt_driver.py +++ b/cinder/tests/unit/targets/test_cxt_driver.py @@ -15,8 +15,7 @@ import os import sys - -import mock +from unittest import mock from cinder import context from cinder import test diff --git a/cinder/tests/unit/targets/test_iet_driver.py b/cinder/tests/unit/targets/test_iet_driver.py index ac613421c9c..30a7fd7c3e6 100644 --- a/cinder/tests/unit/targets/test_iet_driver.py +++ b/cinder/tests/unit/targets/test_iet_driver.py @@ -11,14 +11,13 @@ # under the License. import contextlib +from unittest import mock -import mock from oslo_concurrency import processutils as putils import six from cinder import context from cinder import exception - from cinder.tests.unit.targets import targets_fixture as tf from cinder import utils from cinder.volume.targets import iet diff --git a/cinder/tests/unit/targets/test_iser_driver.py b/cinder/tests/unit/targets/test_iser_driver.py index e817ff4fcd4..5ecc08a41c9 100644 --- a/cinder/tests/unit/targets/test_iser_driver.py +++ b/cinder/tests/unit/targets/test_iser_driver.py @@ -10,7 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from cinder.tests.unit.targets import targets_fixture as tf from cinder import utils diff --git a/cinder/tests/unit/targets/test_lio_driver.py b/cinder/tests/unit/targets/test_lio_driver.py index 44bcabfe722..a759c3bae2d 100644 --- a/cinder/tests/unit/targets/test_lio_driver.py +++ b/cinder/tests/unit/targets/test_lio_driver.py @@ -10,7 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from oslo_concurrency import processutils as putils from cinder import context diff --git a/cinder/tests/unit/targets/test_nvmeof_driver.py b/cinder/tests/unit/targets/test_nvmeof_driver.py index 102a41a6eed..62d707c9408 100644 --- a/cinder/tests/unit/targets/test_nvmeof_driver.py +++ b/cinder/tests/unit/targets/test_nvmeof_driver.py @@ -10,7 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from oslo_utils import timeutils diff --git a/cinder/tests/unit/targets/test_nvmet_driver.py b/cinder/tests/unit/targets/test_nvmet_driver.py index 11dee8ea1ee..61d3718b5f3 100644 --- a/cinder/tests/unit/targets/test_nvmet_driver.py +++ b/cinder/tests/unit/targets/test_nvmet_driver.py @@ -10,7 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from oslo_utils import timeutils diff --git a/cinder/tests/unit/targets/test_scst_driver.py b/cinder/tests/unit/targets/test_scst_driver.py index 918e5192a2d..c9fd323a323 100644 --- a/cinder/tests/unit/targets/test_scst_driver.py +++ b/cinder/tests/unit/targets/test_scst_driver.py @@ -10,7 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from cinder import context from cinder.tests.unit.targets import targets_fixture as tf diff --git a/cinder/tests/unit/targets/test_spdknvmf.py b/cinder/tests/unit/targets/test_spdknvmf.py index 1076b3b7e73..1e76d122787 100644 --- a/cinder/tests/unit/targets/test_spdknvmf.py +++ b/cinder/tests/unit/targets/test_spdknvmf.py @@ -12,7 +12,7 @@ import copy import json -import mock +from unittest import mock from cinder import test from cinder.volume import configuration as conf diff --git a/cinder/tests/unit/targets/test_tgt_driver.py b/cinder/tests/unit/targets/test_tgt_driver.py index 45e2dea818f..4b779e0723b 100644 --- a/cinder/tests/unit/targets/test_tgt_driver.py +++ b/cinder/tests/unit/targets/test_tgt_driver.py @@ -13,8 +13,8 @@ import os import sys import time +from unittest import mock -import mock from oslo_concurrency import processutils as putils from cinder import context diff --git a/cinder/tests/unit/test_api_urlmap.py b/cinder/tests/unit/test_api_urlmap.py index dfa508cfdca..5b81d73c9b1 100644 --- a/cinder/tests/unit/test_api_urlmap.py +++ b/cinder/tests/unit/test_api_urlmap.py @@ -17,7 +17,7 @@ Tests for cinder.api.urlmap.py """ -import mock +from unittest import mock from cinder.api import urlmap from cinder import test diff --git a/cinder/tests/unit/test_cleanable_manager.py b/cinder/tests/unit/test_cleanable_manager.py index e682501d56d..da20e2329e7 100644 --- a/cinder/tests/unit/test_cleanable_manager.py +++ b/cinder/tests/unit/test_cleanable_manager.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from oslo_utils import timeutils diff --git a/cinder/tests/unit/test_cmd.py b/cinder/tests/unit/test_cmd.py index 6b1a6087596..961ebc7a157 100644 --- a/cinder/tests/unit/test_cmd.py +++ b/cinder/tests/unit/test_cmd.py @@ -11,14 +11,14 @@ # under the License. import datetime -import iso8601 import re import sys import time +from unittest import mock import ddt import fixtures -import mock +import iso8601 from oslo_config import cfg from oslo_db import exception as oslo_exception from oslo_utils import timeutils diff --git a/cinder/tests/unit/test_context.py b/cinder/tests/unit/test_context.py index 1df972c9d6d..3bbf9275539 100644 --- a/cinder/tests/unit/test_context.py +++ b/cinder/tests/unit/test_context.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from cinder import context from cinder import test diff --git a/cinder/tests/unit/test_coordination.py b/cinder/tests/unit/test_coordination.py index 33d34145d47..3288bb5d21b 100644 --- a/cinder/tests/unit/test_coordination.py +++ b/cinder/tests/unit/test_coordination.py @@ -14,8 +14,8 @@ # under the License. import inspect +from unittest import mock -import mock import tooz.coordination import tooz.locking diff --git a/cinder/tests/unit/test_db_api.py b/cinder/tests/unit/test_db_api.py index ed98bc63240..b403a6e57b4 100644 --- a/cinder/tests/unit/test_db_api.py +++ b/cinder/tests/unit/test_db_api.py @@ -13,13 +13,12 @@ """Unit tests for cinder.db.api.""" - import datetime +import enum +from unittest import mock +from unittest.mock import call import ddt -import enum -import mock -from mock import call from oslo_config import cfg from oslo_utils import timeutils from oslo_utils import uuidutils diff --git a/cinder/tests/unit/test_db_worker_api.py b/cinder/tests/unit/test_db_worker_api.py index 44721c44951..d7d742cc68c 100644 --- a/cinder/tests/unit/test_db_worker_api.py +++ b/cinder/tests/unit/test_db_worker_api.py @@ -17,9 +17,9 @@ from datetime import datetime import time +from unittest import mock import uuid -import mock from oslo_db import exception as db_exception import six diff --git a/cinder/tests/unit/test_exception.py b/cinder/tests/unit/test_exception.py index f1b080e37d5..f8cba0d3584 100644 --- a/cinder/tests/unit/test_exception.py +++ b/cinder/tests/unit/test_exception.py @@ -15,8 +15,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import fixtures -import mock import six from six.moves import http_client import webob.util diff --git a/cinder/tests/unit/test_hacking.py b/cinder/tests/unit/test_hacking.py index ed63a4fb497..9786461e7d5 100644 --- a/cinder/tests/unit/test_hacking.py +++ b/cinder/tests/unit/test_hacking.py @@ -12,10 +12,10 @@ # License for the specific language governing permissions and limitations # under the License. -import ddt import textwrap +from unittest import mock -import mock +import ddt import pycodestyle from cinder import test diff --git a/cinder/tests/unit/test_image_utils.py b/cinder/tests/unit/test_image_utils.py index f7040ee3a06..d31898bc96f 100644 --- a/cinder/tests/unit/test_image_utils.py +++ b/cinder/tests/unit/test_image_utils.py @@ -14,10 +14,10 @@ import errno import math +from unittest import mock import cryptography import ddt -import mock from oslo_concurrency import processutils from oslo_utils import units from six.moves import builtins diff --git a/cinder/tests/unit/test_interface.py b/cinder/tests/unit/test_interface.py index 9f8f124ed33..321c7937484 100644 --- a/cinder/tests/unit/test_interface.py +++ b/cinder/tests/unit/test_interface.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from cinder.interface import util from cinder import test diff --git a/cinder/tests/unit/test_macrosan_drivers.py b/cinder/tests/unit/test_macrosan_drivers.py index a97c6347849..0f20d130bb8 100644 --- a/cinder/tests/unit/test_macrosan_drivers.py +++ b/cinder/tests/unit/test_macrosan_drivers.py @@ -13,9 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. """Tests for macrosan drivers.""" -import mock import os import socket +from unittest import mock from six.moves import UserDict diff --git a/cinder/tests/unit/test_manager.py b/cinder/tests/unit/test_manager.py index f51e3cc34ea..ea31ae7e0bb 100644 --- a/cinder/tests/unit/test_manager.py +++ b/cinder/tests/unit/test_manager.py @@ -13,7 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + import six from cinder import manager diff --git a/cinder/tests/unit/test_policy.py b/cinder/tests/unit/test_policy.py index 184f0f01c58..6a6277091b8 100644 --- a/cinder/tests/unit/test_policy.py +++ b/cinder/tests/unit/test_policy.py @@ -13,19 +13,18 @@ # License for the specific language governing permissions and limitations # under the License. import os.path +from unittest import mock -import mock from oslo_config import cfg from oslo_config import fixture as config_fixture from oslo_policy import policy as oslo_policy from cinder import context from cinder import exception +from cinder import policy from cinder import test from cinder import utils -from cinder import policy - CONF = cfg.CONF diff --git a/cinder/tests/unit/test_qos_specs.py b/cinder/tests/unit/test_qos_specs.py index 38f38d9f7f3..c83b1c46ebc 100644 --- a/cinder/tests/unit/test_qos_specs.py +++ b/cinder/tests/unit/test_qos_specs.py @@ -13,16 +13,14 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -""" -Unit Tests for qos specs internal API -""" +"""Unit Tests for qos specs internal API.""" -import mock -import six import time +from unittest import mock from oslo_db import exception as db_exc from oslo_utils import timeutils +import six from cinder import context from cinder import db diff --git a/cinder/tests/unit/test_quota.py b/cinder/tests/unit/test_quota.py index c240776121e..d3e304e9c34 100644 --- a/cinder/tests/unit/test_quota.py +++ b/cinder/tests/unit/test_quota.py @@ -16,8 +16,8 @@ # under the License. import datetime +from unittest import mock -import mock from oslo_config import cfg from oslo_config import fixture as config_fixture from oslo_utils import timeutils diff --git a/cinder/tests/unit/test_quota_utils.py b/cinder/tests/unit/test_quota_utils.py index bc27539c47a..5dae9f1f2d6 100644 --- a/cinder/tests/unit/test_quota_utils.py +++ b/cinder/tests/unit/test_quota_utils.py @@ -13,17 +13,17 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + +from keystoneclient import exceptions +from oslo_config import cfg +from oslo_config import fixture as config_fixture from cinder import context from cinder import exception from cinder import quota_utils from cinder import test -from keystoneclient import exceptions - -from oslo_config import cfg -from oslo_config import fixture as config_fixture CONF = cfg.CONF diff --git a/cinder/tests/unit/test_rpc.py b/cinder/tests/unit/test_rpc.py index 87c4f4a0c01..0f378188e95 100644 --- a/cinder/tests/unit/test_rpc.py +++ b/cinder/tests/unit/test_rpc.py @@ -12,8 +12,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from cinder.objects import base from cinder import rpc diff --git a/cinder/tests/unit/test_service.py b/cinder/tests/unit/test_service.py index 9a69c4b95ec..8d7a12494ed 100644 --- a/cinder/tests/unit/test_service.py +++ b/cinder/tests/unit/test_service.py @@ -15,12 +15,11 @@ # License for the specific language governing permissions and limitations # under the License. -""" -Unit Tests for remote procedure calls using queue -""" +"""Unit Tests for remote procedure calls using queue.""" + +from unittest import mock import ddt -import mock from oslo_concurrency import processutils from oslo_config import cfg from oslo_db import exception as db_exc diff --git a/cinder/tests/unit/test_service_auth.py b/cinder/tests/unit/test_service_auth.py index 81394da79a0..808097c31ee 100644 --- a/cinder/tests/unit/test_service_auth.py +++ b/cinder/tests/unit/test_service_auth.py @@ -10,18 +10,18 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + from keystoneauth1.identity.generic import password from keystoneauth1 import loading as ks_loading from keystoneauth1 import service_token -import mock +from oslo_config import cfg from cinder import context from cinder import exception from cinder import service_auth from cinder import test -from oslo_config import cfg - CONF = cfg.CONF diff --git a/cinder/tests/unit/test_setup_profiler.py b/cinder/tests/unit/test_setup_profiler.py index bd9cb0a46f6..a5f65ac9b21 100644 --- a/cinder/tests/unit/test_setup_profiler.py +++ b/cinder/tests/unit/test_setup_profiler.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from cinder.common import constants from cinder import service diff --git a/cinder/tests/unit/test_ssh_utils.py b/cinder/tests/unit/test_ssh_utils.py index 7c86b967960..aa8f1e5efe8 100644 --- a/cinder/tests/unit/test_ssh_utils.py +++ b/cinder/tests/unit/test_ssh_utils.py @@ -10,10 +10,11 @@ # License for the specific language governing permissions and limitations # under the License. -import mock -import paramiko +from unittest import mock import uuid +import paramiko + from cinder import exception from cinder import ssh_utils from cinder import test diff --git a/cinder/tests/unit/test_test.py b/cinder/tests/unit/test_test.py index 659f8e156e4..b9f57c889bd 100644 --- a/cinder/tests/unit/test_test.py +++ b/cinder/tests/unit/test_test.py @@ -17,7 +17,8 @@ """Tests for the testing base code.""" -import mock +from unittest import mock + from oslo_config import cfg import oslo_messaging as messaging diff --git a/cinder/tests/unit/test_utils.py b/cinder/tests/unit/test_utils.py index 61de7f2daa0..35e28f788b6 100644 --- a/cinder/tests/unit/test_utils.py +++ b/cinder/tests/unit/test_utils.py @@ -12,16 +12,15 @@ # License for the specific language governing permissions and limitations # under the License. - import datetime import functools import json import os import sys import time +from unittest import mock import ddt -import mock from oslo_utils import timeutils import six from six.moves import range diff --git a/cinder/tests/unit/test_volume_cleanup.py b/cinder/tests/unit/test_volume_cleanup.py index 9ae3c455d66..664ecefb52d 100644 --- a/cinder/tests/unit/test_volume_cleanup.py +++ b/cinder/tests/unit/test_volume_cleanup.py @@ -13,7 +13,8 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from oslo_config import cfg from cinder import context diff --git a/cinder/tests/unit/test_volume_throttling.py b/cinder/tests/unit/test_volume_throttling.py index edbc2d955f1..22cd561d9dc 100644 --- a/cinder/tests/unit/test_volume_throttling.py +++ b/cinder/tests/unit/test_volume_throttling.py @@ -15,7 +15,7 @@ """Tests for volume copy throttling helpers.""" -import mock +from unittest import mock from cinder import test from cinder import utils diff --git a/cinder/tests/unit/test_volume_transfer.py b/cinder/tests/unit/test_volume_transfer.py index 1a75c12aee8..531c9e33b28 100644 --- a/cinder/tests/unit/test_volume_transfer.py +++ b/cinder/tests/unit/test_volume_transfer.py @@ -12,8 +12,8 @@ # under the License. """Unit Tests for volume transfers.""" +from unittest import mock -import mock from oslo_utils import timeutils from cinder import context diff --git a/cinder/tests/unit/test_volume_types.py b/cinder/tests/unit/test_volume_types.py index a4e56e31944..a4c3451e0d9 100644 --- a/cinder/tests/unit/test_volume_types.py +++ b/cinder/tests/unit/test_volume_types.py @@ -13,10 +13,9 @@ # under the License. """Unit Tests for volume types code.""" - import datetime -import mock import time +from unittest import mock from oslo_db import exception as db_exc from oslo_utils import uuidutils diff --git a/cinder/tests/unit/test_volume_utils.py b/cinder/tests/unit/test_volume_utils.py index cc18ba8e888..113175f2a24 100644 --- a/cinder/tests/unit/test_volume_utils.py +++ b/cinder/tests/unit/test_volume_utils.py @@ -18,14 +18,14 @@ import datetime import io -import mock -import six +from unittest import mock from castellan import key_manager import ddt from oslo_concurrency import processutils from oslo_config import cfg from oslo_utils import units +import six from cinder import context from cinder import db diff --git a/cinder/tests/unit/utils.py b/cinder/tests/unit/utils.py index a31b90d339b..b4e23c35cee 100644 --- a/cinder/tests/unit/utils.py +++ b/cinder/tests/unit/utils.py @@ -14,12 +14,12 @@ # import datetime -import fixtures import socket import sys +from unittest import mock import uuid -import mock +import fixtures from oslo_config import cfg from oslo_service import loopingcall from oslo_utils import timeutils diff --git a/cinder/tests/unit/volume/__init__.py b/cinder/tests/unit/volume/__init__.py index 97824a88f5b..774cd0a88fb 100644 --- a/cinder/tests/unit/volume/__init__.py +++ b/cinder/tests/unit/volume/__init__.py @@ -16,8 +16,8 @@ import os import shutil import tempfile +from unittest import mock -import mock from oslo_config import cfg from oslo_utils import importutils from stevedore import extension diff --git a/cinder/tests/unit/volume/drivers/dell_emc/powermax/powermax_data.py b/cinder/tests/unit/volume/drivers/dell_emc/powermax/powermax_data.py index 2528856dcc5..98f82d38a6c 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/powermax/powermax_data.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/powermax/powermax_data.py @@ -14,6 +14,7 @@ # under the License. from copy import deepcopy + import six from cinder import context diff --git a/cinder/tests/unit/volume/drivers/dell_emc/powermax/powermax_fake_objects.py b/cinder/tests/unit/volume/drivers/dell_emc/powermax/powermax_fake_objects.py index 75f4d85abfa..6ddd67ea19f 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/powermax/powermax_fake_objects.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/powermax/powermax_fake_objects.py @@ -14,6 +14,7 @@ # under the License. import ast + import requests from cinder import exception diff --git a/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_common.py b/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_common.py index 16e7d9620d9..f775cf36f4d 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_common.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_common.py @@ -15,7 +15,8 @@ import ast from copy import deepcopy -import mock +from unittest import mock + import six from cinder import exception diff --git a/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_fc.py b/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_fc.py index e7cedf4188c..0469b4d0a18 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_fc.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_fc.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from cinder import test from cinder.tests.unit.volume.drivers.dell_emc.powermax import ( diff --git a/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_iscsi.py b/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_iscsi.py index 1a7cdaefabc..1fef3e5d8e3 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_iscsi.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_iscsi.py @@ -14,8 +14,7 @@ # under the License. from copy import deepcopy - -import mock +from unittest import mock from cinder import exception from cinder import test diff --git a/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_masking.py b/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_masking.py index 89a771620c9..56eb7a9162c 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_masking.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_masking.py @@ -14,7 +14,7 @@ # under the License. from copy import deepcopy -import mock +from unittest import mock from cinder import exception from cinder import test diff --git a/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_metadata.py b/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_metadata.py index 66f471f8a3b..fd1fa412246 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_metadata.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_metadata.py @@ -13,8 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock import platform +from unittest import mock from cinder.objects import fields from cinder import test diff --git a/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_provision.py b/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_provision.py index 3d83342aa69..1f53b1ab1f3 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_provision.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_provision.py @@ -14,8 +14,7 @@ # under the License. from copy import deepcopy - -import mock +from unittest import mock from cinder import exception from cinder import test diff --git a/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_replication.py b/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_replication.py index 6a22a50978c..e8fc4057912 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_replication.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_replication.py @@ -15,8 +15,8 @@ import ast from copy import deepcopy +from unittest import mock -import mock import six from cinder import exception diff --git a/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_rest.py b/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_rest.py index 6abbb6b2a28..7f5cb9beef8 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_rest.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_rest.py @@ -15,8 +15,8 @@ from copy import deepcopy import time +from unittest import mock -import mock import requests from cinder import exception diff --git a/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_utils.py b/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_utils.py index 60587b3115d..3bd608002f0 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_utils.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_utils.py @@ -15,10 +15,10 @@ from copy import deepcopy import datetime +from unittest import mock from ddt import data from ddt import ddt -import mock import six from cinder import exception diff --git a/cinder/tests/unit/volume/drivers/dell_emc/sc/test_fc.py b/cinder/tests/unit/volume/drivers/dell_emc/sc/test_fc.py index bb2fcb1ce0d..e58758fed26 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/sc/test_fc.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/sc/test_fc.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from cinder import context from cinder import exception diff --git a/cinder/tests/unit/volume/drivers/dell_emc/sc/test_sc.py b/cinder/tests/unit/volume/drivers/dell_emc/sc/test_sc.py index 1b70dad9401..ed8f9028c2d 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/sc/test_sc.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/sc/test_sc.py @@ -12,10 +12,11 @@ # License for the specific language governing permissions and limitations # under the License. -import eventlet -import mock +from unittest import mock import uuid +import eventlet + from cinder import context from cinder import exception from cinder.objects import fields diff --git a/cinder/tests/unit/volume/drivers/dell_emc/sc/test_scapi.py b/cinder/tests/unit/volume/drivers/dell_emc/sc/test_scapi.py index 17c7413164f..4d92b64ac56 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/sc/test_scapi.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/sc/test_scapi.py @@ -12,13 +12,14 @@ # License for the specific language governing permissions and limitations # under the License. +import json +from unittest import mock +import uuid + import ddt import eventlet -import json -import mock import requests from requests import models -import uuid from cinder import context from cinder import exception diff --git a/cinder/tests/unit/volume/drivers/dell_emc/test_ps.py b/cinder/tests/unit/volume/drivers/dell_emc/test_ps.py index 92c3095b54e..0c0a90364fc 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/test_ps.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/test_ps.py @@ -15,9 +15,9 @@ import time import unittest +from unittest import mock from eventlet import greenthread -import mock from oslo_concurrency import processutils import paramiko import six diff --git a/cinder/tests/unit/volume/drivers/dell_emc/test_xtremio.py b/cinder/tests/unit/volume/drivers/dell_emc/test_xtremio.py index 5461f94f18a..5cd90e82b3c 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/test_xtremio.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/test_xtremio.py @@ -16,8 +16,8 @@ import copy import re import time +from unittest import mock -import mock import six from cinder import context diff --git a/cinder/tests/unit/volume/drivers/dell_emc/unity/test_adapter.py b/cinder/tests/unit/volume/drivers/dell_emc/unity/test_adapter.py index 29db065e259..6696f59b6cb 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/unity/test_adapter.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/unity/test_adapter.py @@ -15,9 +15,9 @@ import contextlib import functools +from unittest import mock import ddt -import mock from oslo_utils import units from cinder import exception diff --git a/cinder/tests/unit/volume/drivers/dell_emc/unity/test_client.py b/cinder/tests/unit/volume/drivers/dell_emc/unity/test_client.py index a4c593d5ce8..f60eb853494 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/unity/test_client.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/unity/test_client.py @@ -13,9 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. import unittest +from unittest import mock import ddt -from mock import mock from oslo_utils import units from cinder import coordination diff --git a/cinder/tests/unit/volume/drivers/dell_emc/unity/test_driver.py b/cinder/tests/unit/volume/drivers/dell_emc/unity/test_driver.py index 9d9fa51189b..d766ef5816e 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/unity/test_driver.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/unity/test_driver.py @@ -15,8 +15,7 @@ import functools import unittest - -import mock +from unittest import mock from cinder.tests.unit.volume.drivers.dell_emc.unity \ import fake_exception as ex diff --git a/cinder/tests/unit/volume/drivers/dell_emc/unity/test_replication.py b/cinder/tests/unit/volume/drivers/dell_emc/unity/test_replication.py index f81a1242b37..2e7280833bd 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/unity/test_replication.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/unity/test_replication.py @@ -14,9 +14,9 @@ # under the License. import unittest +from unittest import mock import ddt -from mock import mock from cinder import exception from cinder.volume import configuration as conf diff --git a/cinder/tests/unit/volume/drivers/dell_emc/unity/test_utils.py b/cinder/tests/unit/volume/drivers/dell_emc/unity/test_utils.py index c822c90c5f0..35e4a545bd0 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/unity/test_utils.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/unity/test_utils.py @@ -15,8 +15,8 @@ import functools import unittest +from unittest import mock -import mock from oslo_utils import units from cinder import exception diff --git a/cinder/tests/unit/volume/drivers/dell_emc/vnx/__init__.py b/cinder/tests/unit/volume/drivers/dell_emc/vnx/__init__.py index 69a8bb96280..74cad1c3029 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/vnx/__init__.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/vnx/__init__.py @@ -14,8 +14,7 @@ # under the License. import sys - -import mock +from unittest import mock from cinder.tests.unit.volume.drivers.dell_emc.vnx import fake_exception from cinder.tests.unit.volume.drivers.dell_emc.vnx import fake_storops diff --git a/cinder/tests/unit/volume/drivers/dell_emc/vnx/fake_enum.py b/cinder/tests/unit/volume/drivers/dell_emc/vnx/fake_enum.py index 9a20687b6ec..a56c514e64e 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/vnx/fake_enum.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/vnx/fake_enum.py @@ -14,6 +14,7 @@ # under the License. import enum + import six diff --git a/cinder/tests/unit/volume/drivers/dell_emc/vnx/res_mock.py b/cinder/tests/unit/volume/drivers/dell_emc/vnx/res_mock.py index 83596b12b2f..b721ac38869 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/vnx/res_mock.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/vnx/res_mock.py @@ -13,7 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + import six from cinder import context diff --git a/cinder/tests/unit/volume/drivers/dell_emc/vnx/test_adapter.py b/cinder/tests/unit/volume/drivers/dell_emc/vnx/test_adapter.py index 1768d5a8c5b..4985cc8cd16 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/vnx/test_adapter.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/vnx/test_adapter.py @@ -12,9 +12,9 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -import mock import os import re +from unittest import mock from oslo_config import cfg diff --git a/cinder/tests/unit/volume/drivers/dell_emc/vnx/test_common.py b/cinder/tests/unit/volume/drivers/dell_emc/vnx/test_common.py index 1f4178d5921..fc3c07e7680 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/vnx/test_common.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/vnx/test_common.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from cinder import exception from cinder.tests.unit.volume.drivers.dell_emc.vnx import fake_storops \ diff --git a/cinder/tests/unit/volume/drivers/dell_emc/vnx/test_driver.py b/cinder/tests/unit/volume/drivers/dell_emc/vnx/test_driver.py index 265eb0bfb6e..5fe0023596c 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/vnx/test_driver.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/vnx/test_driver.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from cinder.tests.unit.volume.drivers.dell_emc.vnx import test_base from cinder.volume.drivers.dell_emc.vnx import driver diff --git a/cinder/tests/unit/volume/drivers/dell_emc/vnx/test_replication.py b/cinder/tests/unit/volume/drivers/dell_emc/vnx/test_replication.py index 65cbc53710f..42a82f49457 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/vnx/test_replication.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/vnx/test_replication.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from cinder.objects import fields from cinder.tests.unit.volume.drivers.dell_emc.vnx import res_mock diff --git a/cinder/tests/unit/volume/drivers/dell_emc/vnx/test_utils.py b/cinder/tests/unit/volume/drivers/dell_emc/vnx/test_utils.py index e468ec90d5f..a0e3a1cf9b9 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/vnx/test_utils.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/vnx/test_utils.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from cinder import exception from cinder.tests.unit.volume.drivers.dell_emc.vnx import fake_exception \ diff --git a/cinder/tests/unit/volume/drivers/dell_emc/vnx/utils.py b/cinder/tests/unit/volume/drivers/dell_emc/vnx/utils.py index 9b7deb05ea9..d73e0296012 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/vnx/utils.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/vnx/utils.py @@ -15,8 +15,8 @@ from os import path +from unittest import mock -import mock import six import yaml diff --git a/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/__init__.py b/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/__init__.py index d6efb28b188..2b7cc557bb0 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/__init__.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/__init__.py @@ -13,6 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. import copy + import requests import six diff --git a/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/mocks.py b/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/mocks.py index 352b2971a59..05208c83304 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/mocks.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/mocks.py @@ -13,10 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. import json -import requests -import six from oslo_config import cfg +import requests +import six from cinder.volume.drivers.dell_emc.vxflexos import driver diff --git a/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/test_create_volume.py b/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/test_create_volume.py index 0415f83306c..c7de0b80fd1 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/test_create_volume.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/test_create_volume.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from cinder import context from cinder import exception diff --git a/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/test_get_manageable.py b/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/test_get_manageable.py index e933bcf7db2..b27a660a248 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/test_get_manageable.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/test_get_manageable.py @@ -14,9 +14,9 @@ # under the License. from copy import deepcopy +from unittest import mock import ddt -import mock from cinder.tests.unit import fake_volume from cinder.tests.unit.volume.drivers.dell_emc import vxflexos diff --git a/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/test_groups.py b/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/test_groups.py index 14b6e6b0f38..31a44d1b0e4 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/test_groups.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/test_groups.py @@ -14,11 +14,10 @@ # under the License. import json -import mock +from unittest import mock from cinder import context from cinder.objects import fields - from cinder.tests.unit import fake_constants as fake from cinder.tests.unit import fake_group from cinder.tests.unit import fake_snapshot diff --git a/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/test_initialize_connection.py b/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/test_initialize_connection.py index 1c57cf14bc9..adaf2a1edec 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/test_initialize_connection.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/test_initialize_connection.py @@ -12,7 +12,7 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from cinder import context from cinder.tests.unit import fake_constants as fake diff --git a/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/test_initialize_connection_snapshot.py b/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/test_initialize_connection_snapshot.py index 475e918062c..fdd82b6d6c5 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/test_initialize_connection_snapshot.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/test_initialize_connection_snapshot.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from cinder import context from cinder.tests.unit import fake_constants as fake diff --git a/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/test_manage_existing.py b/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/test_manage_existing.py index 98dfc5e2a1e..3f8154400eb 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/test_manage_existing.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/test_manage_existing.py @@ -13,6 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest.mock import patch + +from six.moves import urllib + from cinder import context from cinder import exception from cinder.tests.unit import fake_constants as fake @@ -20,8 +24,6 @@ from cinder.tests.unit import fake_volume from cinder.tests.unit.volume.drivers.dell_emc import vxflexos from cinder.tests.unit.volume.drivers.dell_emc.vxflexos import mocks from cinder.volume import volume_types -from mock import patch -from six.moves import urllib class TestManageExisting(vxflexos.TestVxFlexOSDriver): diff --git a/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/test_misc.py b/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/test_misc.py index b55795977aa..3915640d67d 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/test_misc.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/vxflexos/test_misc.py @@ -13,9 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. -import ddt import json -import mock +from unittest import mock + +import ddt from cinder import context from cinder import exception diff --git a/cinder/tests/unit/volume/drivers/hpe/fake_hpe_3par_client.py b/cinder/tests/unit/volume/drivers/hpe/fake_hpe_3par_client.py index ebe40268980..52aa6a9ae34 100644 --- a/cinder/tests/unit/volume/drivers/hpe/fake_hpe_3par_client.py +++ b/cinder/tests/unit/volume/drivers/hpe/fake_hpe_3par_client.py @@ -16,8 +16,7 @@ """Fake HPE client for testing 3PAR without installing the client.""" import sys - -import mock +from unittest import mock from cinder.tests.unit.volume.drivers.hpe \ import fake_hpe_client_exceptions as hpeexceptions diff --git a/cinder/tests/unit/volume/drivers/hpe/fake_hpe_lefthand_client.py b/cinder/tests/unit/volume/drivers/hpe/fake_hpe_lefthand_client.py index d4f05ee2029..74331bcf38a 100644 --- a/cinder/tests/unit/volume/drivers/hpe/fake_hpe_lefthand_client.py +++ b/cinder/tests/unit/volume/drivers/hpe/fake_hpe_lefthand_client.py @@ -16,8 +16,7 @@ """Fake HPE client for testing LeftHand without installing the client.""" import sys - -import mock +from unittest import mock from cinder.tests.unit.volume.drivers.hpe \ import fake_hpe_client_exceptions as hpeexceptions diff --git a/cinder/tests/unit/volume/drivers/hpe/test_hpe3par.py b/cinder/tests/unit/volume/drivers/hpe/test_hpe3par.py index bd9ec43cc1a..9d89c4f4716 100644 --- a/cinder/tests/unit/volume/drivers/hpe/test_hpe3par.py +++ b/cinder/tests/unit/volume/drivers/hpe/test_hpe3par.py @@ -16,7 +16,7 @@ import ast import copy -import mock +from unittest import mock from oslo_utils import units from oslo_utils import uuidutils diff --git a/cinder/tests/unit/volume/drivers/hpe/test_hpelefthand.py b/cinder/tests/unit/volume/drivers/hpe/test_hpelefthand.py index aaabc257f88..b3bc69125e7 100644 --- a/cinder/tests/unit/volume/drivers/hpe/test_hpelefthand.py +++ b/cinder/tests/unit/volume/drivers/hpe/test_hpelefthand.py @@ -17,7 +17,8 @@ import copy import json -import mock +from unittest import mock + from oslo_utils import units from cinder import context diff --git a/cinder/tests/unit/volume/drivers/huawei/test_huawei_drivers.py b/cinder/tests/unit/volume/drivers/huawei/test_huawei_drivers.py index 323a708b4a8..d85a0f0a0b2 100644 --- a/cinder/tests/unit/volume/drivers/huawei/test_huawei_drivers.py +++ b/cinder/tests/unit/volume/drivers/huawei/test_huawei_drivers.py @@ -15,16 +15,17 @@ """Tests for huawei drivers.""" import collections import copy -import ddt import json -import mock import re -import requests -import retrying import tempfile +from unittest import mock from xml.dom import minidom from xml.etree import ElementTree +import ddt +import requests +import retrying + from cinder import context from cinder import exception from cinder import objects diff --git a/cinder/tests/unit/volume/drivers/ibm/fake_pyxcli.py b/cinder/tests/unit/volume/drivers/ibm/fake_pyxcli.py index 9cf9cef806d..9a881565ef6 100644 --- a/cinder/tests/unit/volume/drivers/ibm/fake_pyxcli.py +++ b/cinder/tests/unit/volume/drivers/ibm/fake_pyxcli.py @@ -14,8 +14,8 @@ # under the License. # """ Fake pyxcli-client for testing the driver without installing pyxcli""" -import mock import sys +from unittest import mock from cinder.tests.unit.volume.drivers.ibm import fake_pyxcli_exceptions diff --git a/cinder/tests/unit/volume/drivers/ibm/test_ds8k_proxy.py b/cinder/tests/unit/volume/drivers/ibm/test_ds8k_proxy.py index de55377404d..69e61c1c482 100644 --- a/cinder/tests/unit/volume/drivers/ibm/test_ds8k_proxy.py +++ b/cinder/tests/unit/volume/drivers/ibm/test_ds8k_proxy.py @@ -16,10 +16,11 @@ """Tests for the IBM DS8K family driver.""" import ast import copy +import json +from unittest import mock + import ddt import eventlet -import json -import mock import six from cinder import context @@ -32,7 +33,6 @@ import cinder.volume.drivers.ibm.ibm_storage as storage from cinder.volume.drivers.ibm.ibm_storage import proxy from cinder.volume import group_types from cinder.volume import volume_types - # mock decorator logger for all unit test cases. mock_logger = mock.patch.object(proxy, 'logger', lambda x: x) mock_logger.start() diff --git a/cinder/tests/unit/volume/drivers/ibm/test_ibm_flashsystem.py b/cinder/tests/unit/volume/drivers/ibm/test_ibm_flashsystem.py index 8611b822c06..72944c9c4d1 100644 --- a/cinder/tests/unit/volume/drivers/ibm/test_ibm_flashsystem.py +++ b/cinder/tests/unit/volume/drivers/ibm/test_ibm_flashsystem.py @@ -17,14 +17,14 @@ """Tests for the IBM FlashSystem volume driver.""" -import mock +import random +import re +from unittest import mock + from oslo_concurrency import processutils from oslo_utils import units import six -import random -import re - from cinder import context from cinder import exception from cinder import test diff --git a/cinder/tests/unit/volume/drivers/ibm/test_ibm_flashsystem_iscsi.py b/cinder/tests/unit/volume/drivers/ibm/test_ibm_flashsystem_iscsi.py index bd53b3ddea6..bbfa41c1534 100644 --- a/cinder/tests/unit/volume/drivers/ibm/test_ibm_flashsystem_iscsi.py +++ b/cinder/tests/unit/volume/drivers/ibm/test_ibm_flashsystem_iscsi.py @@ -14,14 +14,12 @@ # under the License. # -""" -Tests for the IBM FlashSystem iSCSI volume driver. -""" - -import mock -import six +"""Tests for the IBM FlashSystem iSCSI volume driver.""" import random +from unittest import mock + +import six from cinder import context from cinder import exception diff --git a/cinder/tests/unit/volume/drivers/ibm/test_ibm_storage.py b/cinder/tests/unit/volume/drivers/ibm/test_ibm_storage.py index 545120b2023..14ed864fad8 100644 --- a/cinder/tests/unit/volume/drivers/ibm/test_ibm_storage.py +++ b/cinder/tests/unit/volume/drivers/ibm/test_ibm_storage.py @@ -16,8 +16,7 @@ import copy - -import mock +from unittest import mock from cinder import context from cinder import exception diff --git a/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py b/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py index be8102ef337..c1c6bdb42bd 100644 --- a/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py +++ b/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py @@ -14,22 +14,20 @@ # License for the specific language governing permissions and limitations # under the License. # -""" -Tests for the IBM Storwize family and SVC volume driver. -""" +"""Tests for the IBM Storwize family and SVC volume driver.""" -import ddt import json -import mock -import paramiko import random import re import time +from unittest import mock +import ddt from oslo_concurrency import processutils from oslo_config import cfg from oslo_utils import importutils from oslo_utils import units +import paramiko import six from cinder import context diff --git a/cinder/tests/unit/volume/drivers/ibm/test_xiv_proxy.py b/cinder/tests/unit/volume/drivers/ibm/test_xiv_proxy.py index 3ed2acb3822..b34ccb2cfe7 100644 --- a/cinder/tests/unit/volume/drivers/ibm/test_xiv_proxy.py +++ b/cinder/tests/unit/volume/drivers/ibm/test_xiv_proxy.py @@ -13,10 +13,11 @@ # License for the specific language governing permissions and limitations # under the License. # -import mock -import six +from unittest import mock from xml.etree import ElementTree +import six + from cinder import context from cinder import exception from cinder import objects diff --git a/cinder/tests/unit/volume/drivers/infortrend/test_infortrend_cli.py b/cinder/tests/unit/volume/drivers/infortrend/test_infortrend_cli.py index 2c44b1f80f7..17a9d4b6192 100644 --- a/cinder/tests/unit/volume/drivers/infortrend/test_infortrend_cli.py +++ b/cinder/tests/unit/volume/drivers/infortrend/test_infortrend_cli.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from cinder import test from cinder.volume.drivers.infortrend.raidcmd_cli import cli_factory as cli diff --git a/cinder/tests/unit/volume/drivers/infortrend/test_infortrend_common.py b/cinder/tests/unit/volume/drivers/infortrend/test_infortrend_common.py index d9f72ee67a1..efafcb3a50d 100644 --- a/cinder/tests/unit/volume/drivers/infortrend/test_infortrend_common.py +++ b/cinder/tests/unit/volume/drivers/infortrend/test_infortrend_common.py @@ -14,8 +14,7 @@ # under the License. import copy - -import mock +from unittest import mock from cinder import exception from cinder import test diff --git a/cinder/tests/unit/volume/drivers/inspur/as13000/test_as13000_driver.py b/cinder/tests/unit/volume/drivers/inspur/as13000/test_as13000_driver.py index 5ee2891d683..6ef065d7998 100644 --- a/cinder/tests/unit/volume/drivers/inspur/as13000/test_as13000_driver.py +++ b/cinder/tests/unit/volume/drivers/inspur/as13000/test_as13000_driver.py @@ -13,14 +13,12 @@ # License for the specific language governing permissions and limitations # under the License. -""" -Volume driver test for Inspur AS13000 -""" +"""Volume driver test for Inspur AS13000.""" import json -import mock import random import time +from unittest import mock import ddt import eventlet diff --git a/cinder/tests/unit/volume/drivers/inspur/instorage/fakes.py b/cinder/tests/unit/volume/drivers/inspur/instorage/fakes.py index f1f3b3f80da..46f32fc3655 100644 --- a/cinder/tests/unit/volume/drivers/inspur/instorage/fakes.py +++ b/cinder/tests/unit/volume/drivers/inspur/instorage/fakes.py @@ -13,9 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. # -""" -Tests for the Inspur InStorage volume driver. -""" +"""Tests for the Inspur InStorage volume driver.""" import re @@ -25,7 +23,6 @@ import six from cinder import exception from cinder import utils - from cinder.volume.drivers.inspur.instorage import instorage_const from cinder.volume.drivers.inspur.instorage import instorage_fc from cinder.volume.drivers.inspur.instorage import instorage_iscsi diff --git a/cinder/tests/unit/volume/drivers/inspur/instorage/test_common.py b/cinder/tests/unit/volume/drivers/inspur/instorage/test_common.py index 2d921866493..fbb58fc0e4a 100644 --- a/cinder/tests/unit/volume/drivers/inspur/instorage/test_common.py +++ b/cinder/tests/unit/volume/drivers/inspur/instorage/test_common.py @@ -13,13 +13,12 @@ # License for the specific language governing permissions and limitations # under the License. # -""" -Tests for the Inspur InStorage volume driver. -""" +"""Tests for the Inspur InStorage volume driver.""" + +from unittest import mock import ddt from eventlet import greenthread -import mock from oslo_concurrency import processutils from oslo_config import cfg from oslo_utils import importutils @@ -33,6 +32,7 @@ from cinder.objects import fields from cinder import ssh_utils from cinder import test from cinder.tests.unit import utils as testutils +from cinder.tests.unit.volume.drivers.inspur.instorage import fakes from cinder.volume import configuration as conf from cinder.volume.drivers.inspur.instorage import ( replication as instorage_rep) @@ -42,8 +42,6 @@ from cinder.volume import qos_specs from cinder.volume import volume_types from cinder.volume import volume_utils -from cinder.tests.unit.volume.drivers.inspur.instorage import fakes - CONF = cfg.CONF diff --git a/cinder/tests/unit/volume/drivers/inspur/instorage/test_fc_driver.py b/cinder/tests/unit/volume/drivers/inspur/instorage/test_fc_driver.py index 05e652f9c8f..80c80ebbcce 100644 --- a/cinder/tests/unit/volume/drivers/inspur/instorage/test_fc_driver.py +++ b/cinder/tests/unit/volume/drivers/inspur/instorage/test_fc_driver.py @@ -13,12 +13,11 @@ # License for the specific language governing permissions and limitations # under the License. # -""" -Tests for the Inspur InStorage volume driver. -""" +"""Tests for the Inspur InStorage volume driver.""" + +from unittest import mock from eventlet import greenthread -import mock from oslo_utils import importutils from cinder import context diff --git a/cinder/tests/unit/volume/drivers/inspur/instorage/test_helper_routines.py b/cinder/tests/unit/volume/drivers/inspur/instorage/test_helper_routines.py index 0e7097ff85a..16a151c0272 100644 --- a/cinder/tests/unit/volume/drivers/inspur/instorage/test_helper_routines.py +++ b/cinder/tests/unit/volume/drivers/inspur/instorage/test_helper_routines.py @@ -13,20 +13,18 @@ # License for the specific language governing permissions and limitations # under the License. # -""" -Tests for the Inspur InStorage volume driver. -""" +"""Tests for the Inspur InStorage volume driver.""" + +from unittest import mock import ddt -import mock from cinder import exception from cinder import test +from cinder.tests.unit.volume.drivers.inspur.instorage import fakes from cinder.volume import configuration as conf from cinder.volume.drivers.inspur.instorage import instorage_common -from cinder.tests.unit.volume.drivers.inspur.instorage import fakes - class CLIParserTestCase(test.TestCase): diff --git a/cinder/tests/unit/volume/drivers/inspur/instorage/test_iscsi_driver.py b/cinder/tests/unit/volume/drivers/inspur/instorage/test_iscsi_driver.py index f672d217817..7c7160e5030 100644 --- a/cinder/tests/unit/volume/drivers/inspur/instorage/test_iscsi_driver.py +++ b/cinder/tests/unit/volume/drivers/inspur/instorage/test_iscsi_driver.py @@ -13,12 +13,11 @@ # License for the specific language governing permissions and limitations # under the License. # -""" -Tests for the Inspur InStorage volume driver. -""" +"""Tests for the Inspur InStorage volume driver.""" + +from unittest import mock from eventlet import greenthread -import mock from oslo_utils import importutils import six @@ -26,12 +25,11 @@ from cinder import context from cinder import exception from cinder import test from cinder.tests.unit import utils as testutils +from cinder.tests.unit.volume.drivers.inspur.instorage import fakes from cinder.volume import configuration as conf from cinder.volume.drivers.inspur.instorage import instorage_iscsi from cinder.volume import volume_types -from cinder.tests.unit.volume.drivers.inspur.instorage import fakes - class InStorageMCSISCSIDriverTestCase(test.TestCase): def setUp(self): diff --git a/cinder/tests/unit/volume/drivers/inspur/instorage/test_replication.py b/cinder/tests/unit/volume/drivers/inspur/instorage/test_replication.py index c5a1315d74f..26f4b011000 100644 --- a/cinder/tests/unit/volume/drivers/inspur/instorage/test_replication.py +++ b/cinder/tests/unit/volume/drivers/inspur/instorage/test_replication.py @@ -13,14 +13,12 @@ # License for the specific language governing permissions and limitations # under the License. # -""" -Tests for the Inspur InStorage volume driver. -""" +"""Tests for the Inspur InStorage volume driver.""" import json +from unittest import mock from eventlet import greenthread -import mock from oslo_utils import importutils from oslo_utils import units @@ -30,6 +28,7 @@ from cinder.objects import fields from cinder import test from cinder.tests.unit import fake_constants as fake from cinder.tests.unit import utils as testutils +from cinder.tests.unit.volume.drivers.inspur.instorage import fakes from cinder import utils from cinder.volume import configuration as conf from cinder.volume.drivers.inspur.instorage import ( @@ -38,8 +37,6 @@ from cinder.volume.drivers.inspur.instorage import instorage_common from cinder.volume.drivers.inspur.instorage import instorage_const from cinder.volume import volume_types -from cinder.tests.unit.volume.drivers.inspur.instorage import fakes - class InStorageMCSReplicationTestCase(test.TestCase): diff --git a/cinder/tests/unit/volume/drivers/nec/test_volume.py b/cinder/tests/unit/volume/drivers/nec/test_volume.py index 8646dc9e1ca..34e67e34a3e 100644 --- a/cinder/tests/unit/volume/drivers/nec/test_volume.py +++ b/cinder/tests/unit/volume/drivers/nec/test_volume.py @@ -14,9 +14,10 @@ # License for the specific language governing permissions and limitations # under the License. -import ddt -import mock import time +from unittest import mock + +import ddt from cinder import context from cinder import exception diff --git a/cinder/tests/unit/volume/drivers/netapp/dataontap/client/fakes.py b/cinder/tests/unit/volume/drivers/netapp/dataontap/client/fakes.py index 84c21982168..5d8ce26087d 100644 --- a/cinder/tests/unit/volume/drivers/netapp/dataontap/client/fakes.py +++ b/cinder/tests/unit/volume/drivers/netapp/dataontap/client/fakes.py @@ -13,9 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock from lxml import etree -import mock from six.moves import urllib from cinder.tests.unit.volume.drivers.netapp.dataontap import fakes as fake diff --git a/cinder/tests/unit/volume/drivers/netapp/dataontap/client/test_api.py b/cinder/tests/unit/volume/drivers/netapp/dataontap/client/test_api.py index 143732b1a0d..45c9a5d32cc 100644 --- a/cinder/tests/unit/volume/drivers/netapp/dataontap/client/test_api.py +++ b/cinder/tests/unit/volume/drivers/netapp/dataontap/client/test_api.py @@ -15,12 +15,12 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -""" -Tests for NetApp API layer -""" +"""Tests for NetApp API layer""" + +from unittest import mock + import ddt from lxml import etree -import mock from oslo_utils import netutils import paramiko import six diff --git a/cinder/tests/unit/volume/drivers/netapp/dataontap/client/test_client_base.py b/cinder/tests/unit/volume/drivers/netapp/dataontap/client/test_client_base.py index 8d18e07cb4c..e8e406bf0b3 100644 --- a/cinder/tests/unit/volume/drivers/netapp/dataontap/client/test_client_base.py +++ b/cinder/tests/unit/volume/drivers/netapp/dataontap/client/test_client_base.py @@ -14,12 +14,12 @@ # License for the specific language governing permissions and limitations # under the License. +import time +from unittest import mock import uuid from lxml import etree -import mock import six -import time from cinder import exception from cinder import test diff --git a/cinder/tests/unit/volume/drivers/netapp/dataontap/client/test_client_cmode.py b/cinder/tests/unit/volume/drivers/netapp/dataontap/client/test_client_cmode.py index 2e9169fa286..ac20aa4ef6a 100644 --- a/cinder/tests/unit/volume/drivers/netapp/dataontap/client/test_client_cmode.py +++ b/cinder/tests/unit/volume/drivers/netapp/dataontap/client/test_client_cmode.py @@ -16,14 +16,14 @@ # under the License. import copy +import time +from unittest import mock import uuid import ddt from lxml import etree -import mock import paramiko import six -import time from cinder import exception from cinder import ssh_utils diff --git a/cinder/tests/unit/volume/drivers/netapp/dataontap/performance/test_perf_base.py b/cinder/tests/unit/volume/drivers/netapp/dataontap/performance/test_perf_base.py index 9834964cb0e..6b4777baf1c 100644 --- a/cinder/tests/unit/volume/drivers/netapp/dataontap/performance/test_perf_base.py +++ b/cinder/tests/unit/volume/drivers/netapp/dataontap/performance/test_perf_base.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from cinder import exception from cinder import test diff --git a/cinder/tests/unit/volume/drivers/netapp/dataontap/performance/test_perf_cmode.py b/cinder/tests/unit/volume/drivers/netapp/dataontap/performance/test_perf_cmode.py index 9fbef42016d..3db7e6ae4ad 100644 --- a/cinder/tests/unit/volume/drivers/netapp/dataontap/performance/test_perf_cmode.py +++ b/cinder/tests/unit/volume/drivers/netapp/dataontap/performance/test_perf_cmode.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import ddt -import mock from cinder import test from cinder.tests.unit.volume.drivers.netapp.dataontap.performance \ diff --git a/cinder/tests/unit/volume/drivers/netapp/dataontap/test_block_base.py b/cinder/tests/unit/volume/drivers/netapp/dataontap/test_block_base.py index 91dc5b0cf5a..70d3fa285c2 100644 --- a/cinder/tests/unit/volume/drivers/netapp/dataontap/test_block_base.py +++ b/cinder/tests/unit/volume/drivers/netapp/dataontap/test_block_base.py @@ -18,15 +18,13 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -""" -Mock unit tests for the NetApp block storage library -""" +"""Mock unit tests for the NetApp block storage library""" import copy +from unittest import mock import uuid import ddt -import mock from oslo_log import versionutils from oslo_utils import units import six diff --git a/cinder/tests/unit/volume/drivers/netapp/dataontap/test_block_cmode.py b/cinder/tests/unit/volume/drivers/netapp/dataontap/test_block_cmode.py index 8d5832efe3c..5af32a013a9 100644 --- a/cinder/tests/unit/volume/drivers/netapp/dataontap/test_block_cmode.py +++ b/cinder/tests/unit/volume/drivers/netapp/dataontap/test_block_cmode.py @@ -14,12 +14,11 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -""" -Mock unit tests for the NetApp block storage C-mode library -""" +"""Mock unit tests for the NetApp block storage C-mode library.""" + +from unittest import mock import ddt -import mock from cinder import exception from cinder.objects import fields diff --git a/cinder/tests/unit/volume/drivers/netapp/dataontap/test_nfs_base.py b/cinder/tests/unit/volume/drivers/netapp/dataontap/test_nfs_base.py index de0314ea9cd..0d5914ecd17 100644 --- a/cinder/tests/unit/volume/drivers/netapp/dataontap/test_nfs_base.py +++ b/cinder/tests/unit/volume/drivers/netapp/dataontap/test_nfs_base.py @@ -13,16 +13,14 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -""" -Unit tests for the NetApp NFS storage driver -""" +"""Unit tests for the NetApp NFS storage driver.""" import copy import os import threading import time +from unittest import mock import ddt -import mock from os_brick.remotefs import remotefs as remotefs_brick from oslo_concurrency import processutils from oslo_utils import units diff --git a/cinder/tests/unit/volume/drivers/netapp/dataontap/test_nfs_cmode.py b/cinder/tests/unit/volume/drivers/netapp/dataontap/test_nfs_cmode.py index fcabf513615..9ffd67a1472 100644 --- a/cinder/tests/unit/volume/drivers/netapp/dataontap/test_nfs_cmode.py +++ b/cinder/tests/unit/volume/drivers/netapp/dataontap/test_nfs_cmode.py @@ -12,15 +12,13 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -""" -Mock unit tests for the NetApp cmode nfs storage driver -""" +"""Mock unit tests for the NetApp cmode nfs storage driver.""" import hashlib +from unittest import mock import uuid import ddt -import mock from os_brick.remotefs import remotefs as remotefs_brick from oslo_utils import units diff --git a/cinder/tests/unit/volume/drivers/netapp/dataontap/utils/test_capabilities.py b/cinder/tests/unit/volume/drivers/netapp/dataontap/utils/test_capabilities.py index 42d8b0f655e..5b1f8a11c08 100644 --- a/cinder/tests/unit/volume/drivers/netapp/dataontap/utils/test_capabilities.py +++ b/cinder/tests/unit/volume/drivers/netapp/dataontap/utils/test_capabilities.py @@ -15,9 +15,9 @@ import collections import copy +from unittest import mock import ddt -import mock import six from cinder import exception diff --git a/cinder/tests/unit/volume/drivers/netapp/dataontap/utils/test_data_motion.py b/cinder/tests/unit/volume/drivers/netapp/dataontap/utils/test_data_motion.py index cb33c92b9fe..e7a491570ef 100644 --- a/cinder/tests/unit/volume/drivers/netapp/dataontap/utils/test_data_motion.py +++ b/cinder/tests/unit/volume/drivers/netapp/dataontap/utils/test_data_motion.py @@ -10,11 +10,11 @@ # License for the specific language governing permissions and limitations # under the License. -import time - import copy +import time +from unittest import mock + import ddt -import mock from oslo_config import cfg from cinder import test diff --git a/cinder/tests/unit/volume/drivers/netapp/dataontap/utils/test_loopingcalls.py b/cinder/tests/unit/volume/drivers/netapp/dataontap/utils/test_loopingcalls.py index 201474d9da5..57e3b3a9c81 100644 --- a/cinder/tests/unit/volume/drivers/netapp/dataontap/utils/test_loopingcalls.py +++ b/cinder/tests/unit/volume/drivers/netapp/dataontap/utils/test_loopingcalls.py @@ -12,7 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from oslo_service import loopingcall from cinder import test diff --git a/cinder/tests/unit/volume/drivers/netapp/dataontap/utils/test_utils.py b/cinder/tests/unit/volume/drivers/netapp/dataontap/utils/test_utils.py index 755f2ef6466..055d82b1b5b 100644 --- a/cinder/tests/unit/volume/drivers/netapp/dataontap/utils/test_utils.py +++ b/cinder/tests/unit/volume/drivers/netapp/dataontap/utils/test_utils.py @@ -12,9 +12,9 @@ import json import socket +from unittest import mock import ddt -import mock from oslo_config import cfg from cinder import exception diff --git a/cinder/tests/unit/volume/drivers/netapp/test_utils.py b/cinder/tests/unit/volume/drivers/netapp/test_utils.py index 4d4749779db..9a0798f4589 100644 --- a/cinder/tests/unit/volume/drivers/netapp/test_utils.py +++ b/cinder/tests/unit/volume/drivers/netapp/test_utils.py @@ -19,10 +19,10 @@ Mock unit tests for the NetApp driver utility module """ import copy -import ddt import platform +from unittest import mock -import mock +import ddt from oslo_concurrency import processutils as putils from cinder import context diff --git a/cinder/tests/unit/volume/drivers/nexenta/test_nexenta.py b/cinder/tests/unit/volume/drivers/nexenta/test_nexenta.py index 0033126aaf7..f045e1b414a 100644 --- a/cinder/tests/unit/volume/drivers/nexenta/test_nexenta.py +++ b/cinder/tests/unit/volume/drivers/nexenta/test_nexenta.py @@ -12,12 +12,11 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -""" -Unit tests for OpenStack Cinder volume driver -""" +"""Unit tests for OpenStack Cinder volume driver.""" + +from unittest import mock +from unittest.mock import patch -import mock -from mock import patch from oslo_utils import units from cinder import context diff --git a/cinder/tests/unit/volume/drivers/nexenta/test_nexenta5_iscsi.py b/cinder/tests/unit/volume/drivers/nexenta/test_nexenta5_iscsi.py index 83a0a3a26bc..6802ca299e0 100644 --- a/cinder/tests/unit/volume/drivers/nexenta/test_nexenta5_iscsi.py +++ b/cinder/tests/unit/volume/drivers/nexenta/test_nexenta5_iscsi.py @@ -12,12 +12,10 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -""" -Unit tests for OpenStack Cinder volume driver -""" +"""Unit tests for OpenStack Cinder volume driver.""" +from unittest import mock import uuid -import mock from oslo_utils import units from cinder import context diff --git a/cinder/tests/unit/volume/drivers/nexenta/test_nexenta5_jsonrpc.py b/cinder/tests/unit/volume/drivers/nexenta/test_nexenta5_jsonrpc.py index 8203c5ec8d1..817dca2afac 100644 --- a/cinder/tests/unit/volume/drivers/nexenta/test_nexenta5_jsonrpc.py +++ b/cinder/tests/unit/volume/drivers/nexenta/test_nexenta5_jsonrpc.py @@ -12,17 +12,15 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -""" -Unit tests for NexentaStor 5 REST API helper -""" +"""Unit tests for NexentaStor 5 REST API helper.""" import copy import hashlib import json import posixpath +from unittest import mock import uuid -import mock import requests import six diff --git a/cinder/tests/unit/volume/drivers/nexenta/test_nexenta5_nfs.py b/cinder/tests/unit/volume/drivers/nexenta/test_nexenta5_nfs.py index 4feeac219d8..ec40b16e193 100644 --- a/cinder/tests/unit/volume/drivers/nexenta/test_nexenta5_nfs.py +++ b/cinder/tests/unit/volume/drivers/nexenta/test_nexenta5_nfs.py @@ -12,13 +12,11 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -""" -Unit tests for OpenStack Cinder volume driver -""" +"""Unit tests for OpenStack Cinder volume driver.""" import hashlib import os +from unittest import mock -import mock from oslo_utils import units from cinder import context diff --git a/cinder/tests/unit/volume/drivers/solidfire/test_solidfire.py b/cinder/tests/unit/volume/drivers/solidfire/test_solidfire.py index 5d74e46238a..bd9bfd30313 100644 --- a/cinder/tests/unit/volume/drivers/solidfire/test_solidfire.py +++ b/cinder/tests/unit/volume/drivers/solidfire/test_solidfire.py @@ -16,15 +16,15 @@ import datetime import re -import six +from unittest import mock from ddt import data from ddt import ddt from ddt import file_data from ddt import unpack -import mock from oslo_utils import timeutils from oslo_utils import units +import six from cinder import context from cinder import exception diff --git a/cinder/tests/unit/volume/drivers/synology/test_synology_common.py b/cinder/tests/unit/volume/drivers/synology/test_synology_common.py index 0f1cdb275e3..fa1d289c051 100644 --- a/cinder/tests/unit/volume/drivers/synology/test_synology_common.py +++ b/cinder/tests/unit/volume/drivers/synology/test_synology_common.py @@ -18,11 +18,11 @@ import copy import json import math +from unittest import mock from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives.asymmetric import padding from cryptography.hazmat.primitives.asymmetric import rsa -import mock from oslo_utils import units import requests from six.moves import http_client diff --git a/cinder/tests/unit/volume/drivers/synology/test_synology_iscsi.py b/cinder/tests/unit/volume/drivers/synology/test_synology_iscsi.py index e741bc753b2..d372d8eef38 100644 --- a/cinder/tests/unit/volume/drivers/synology/test_synology_iscsi.py +++ b/cinder/tests/unit/volume/drivers/synology/test_synology_iscsi.py @@ -15,7 +15,7 @@ """Tests for the Synology iSCSI volume driver.""" -import mock +from unittest import mock from cinder import exception from cinder import test diff --git a/cinder/tests/unit/volume/drivers/test_datera.py b/cinder/tests/unit/volume/drivers/test_datera.py index 2ffc5d1351d..1260c32eafe 100644 --- a/cinder/tests/unit/volume/drivers/test_datera.py +++ b/cinder/tests/unit/volume/drivers/test_datera.py @@ -13,7 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + import six from cinder import context diff --git a/cinder/tests/unit/volume/drivers/test_fujitsu_dx.py b/cinder/tests/unit/volume/drivers/test_fujitsu_dx.py index ad62196e695..3fd099d4f35 100644 --- a/cinder/tests/unit/volume/drivers/test_fujitsu_dx.py +++ b/cinder/tests/unit/volume/drivers/test_fujitsu_dx.py @@ -14,11 +14,11 @@ # License for the specific language governing permissions and limitations # under the License. -import mock -import six import tempfile +from unittest import mock from oslo_utils import units +import six from cinder import exception from cinder import test diff --git a/cinder/tests/unit/volume/drivers/test_gpfs.py b/cinder/tests/unit/volume/drivers/test_gpfs.py index f8021171f0a..77f331b6ce0 100644 --- a/cinder/tests/unit/volume/drivers/test_gpfs.py +++ b/cinder/tests/unit/volume/drivers/test_gpfs.py @@ -15,8 +15,8 @@ import os import tempfile +from unittest import mock -import mock from oslo_concurrency import processutils from oslo_config import cfg from oslo_utils import units diff --git a/cinder/tests/unit/volume/drivers/test_hedvig.py b/cinder/tests/unit/volume/drivers/test_hedvig.py index bad66b14f71..afa57070f17 100644 --- a/cinder/tests/unit/volume/drivers/test_hedvig.py +++ b/cinder/tests/unit/volume/drivers/test_hedvig.py @@ -14,7 +14,7 @@ # under the License. # -import mock +from unittest import mock from cinder import context from cinder import exception diff --git a/cinder/tests/unit/volume/drivers/test_infinidat.py b/cinder/tests/unit/volume/drivers/test_infinidat.py index 62c4190d069..e3af8fad1e8 100644 --- a/cinder/tests/unit/volume/drivers/test_infinidat.py +++ b/cinder/tests/unit/volume/drivers/test_infinidat.py @@ -15,10 +15,11 @@ """Unit tests for INFINIDAT InfiniBox volume driver.""" import functools -import mock -from oslo_utils import units import platform import socket +from unittest import mock + +from oslo_utils import units from cinder import exception from cinder import test diff --git a/cinder/tests/unit/volume/drivers/test_kaminario.py b/cinder/tests/unit/volume/drivers/test_kaminario.py index 4b770f69ee6..1b264e10cda 100644 --- a/cinder/tests/unit/volume/drivers/test_kaminario.py +++ b/cinder/tests/unit/volume/drivers/test_kaminario.py @@ -14,11 +14,11 @@ # under the License. """Unit tests for kaminario driver.""" import re +import time +from unittest import mock import ddt -import mock from oslo_utils import units -import time from cinder import context from cinder import exception diff --git a/cinder/tests/unit/volume/drivers/test_linstordrv.py b/cinder/tests/unit/volume/drivers/test_linstordrv.py index ab236c3f5cf..694f2842ce5 100644 --- a/cinder/tests/unit/volume/drivers/test_linstordrv.py +++ b/cinder/tests/unit/volume/drivers/test_linstordrv.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from oslo_config import cfg from oslo_utils import timeutils diff --git a/cinder/tests/unit/volume/drivers/test_lvm_driver.py b/cinder/tests/unit/volume/drivers/test_lvm_driver.py index 72e9f3f2abf..27f00fe064e 100644 --- a/cinder/tests/unit/volume/drivers/test_lvm_driver.py +++ b/cinder/tests/unit/volume/drivers/test_lvm_driver.py @@ -10,11 +10,11 @@ # License for the specific language governing permissions and limitations # under the License. -import ddt import os import socket +from unittest import mock -import mock +import ddt from oslo_concurrency import processutils from oslo_config import cfg diff --git a/cinder/tests/unit/volume/drivers/test_nfs.py b/cinder/tests/unit/volume/drivers/test_nfs.py index b4ac4bfd844..c5f1570e3b2 100644 --- a/cinder/tests/unit/volume/drivers/test_nfs.py +++ b/cinder/tests/unit/volume/drivers/test_nfs.py @@ -14,15 +14,15 @@ # under the License. """Unit tests for the NFS driver module.""" -import ddt import errno import os -import six +from unittest import mock import uuid -import mock +import ddt from oslo_utils import imageutils from oslo_utils import units +import six from cinder import context from cinder import exception diff --git a/cinder/tests/unit/volume/drivers/test_pure.py b/cinder/tests/unit/volume/drivers/test_pure.py index 6a4cb6537f8..83f98a291b8 100644 --- a/cinder/tests/unit/volume/drivers/test_pure.py +++ b/cinder/tests/unit/volume/drivers/test_pure.py @@ -15,9 +15,9 @@ from copy import deepcopy import sys +from unittest import mock import ddt -import mock from oslo_utils import units from six.moves import http_client @@ -42,7 +42,7 @@ def fake_retry(exceptions, interval=1, retries=3, backoff_rate=2): patch_retry = mock.patch('cinder.utils.retry', fake_retry) patch_retry.start() sys.modules['purestorage'] = mock.Mock() -from cinder.volume.drivers import pure +from cinder.volume.drivers import pure # noqa # Only mock utils.retry for cinder.volume.drivers.pure import patch_retry.stop() diff --git a/cinder/tests/unit/volume/drivers/test_qnap.py b/cinder/tests/unit/volume/drivers/test_qnap.py index 7c3e925f1a3..a127c66bec0 100644 --- a/cinder/tests/unit/volume/drivers/test_qnap.py +++ b/cinder/tests/unit/volume/drivers/test_qnap.py @@ -14,14 +14,14 @@ # under the License. import base64 -from collections import OrderedDict +import collections +from unittest import mock from ddt import data from ddt import ddt from ddt import unpack from defusedxml import cElementTree as ET import eventlet -import mock from oslo_config import cfg from oslo_utils import units import requests @@ -40,11 +40,11 @@ FAKE_LUNNAA = {'LUNNAA': 'fakeLunNaa'} FAKE_SNAPSHOT = {'snapshot_id': 'fakeSnapshotId'} FAKE_PASSWORD = 'qnapadmin' -FAKE_PARMS = OrderedDict() +FAKE_PARMS = collections.OrderedDict() FAKE_PARMS['pwd'] = base64.b64encode(FAKE_PASSWORD.encode("utf-8")) FAKE_PARMS['serviceKey'] = 1 FAKE_PARMS['user'] = 'admin' -sanitized_params = OrderedDict() +sanitized_params = collections.OrderedDict() for key in FAKE_PARMS: value = FAKE_PARMS[key] diff --git a/cinder/tests/unit/volume/drivers/test_quobyte.py b/cinder/tests/unit/volume/drivers/test_quobyte.py index e5fe434f067..9a37614b37f 100644 --- a/cinder/tests/unit/volume/drivers/test_quobyte.py +++ b/cinder/tests/unit/volume/drivers/test_quobyte.py @@ -15,19 +15,19 @@ # under the License. """Unit tests for the Quobyte driver module.""" -import ddt import errno import os -import psutil import shutil -import six import traceback +from unittest import mock -import mock +import ddt from oslo_concurrency import processutils as putils from oslo_utils import fileutils from oslo_utils import imageutils from oslo_utils import units +import psutil +import six from cinder import context from cinder import exception diff --git a/cinder/tests/unit/volume/drivers/test_rbd.py b/cinder/tests/unit/volume/drivers/test_rbd.py index bd65f37d8b5..5c3e262ab5f 100644 --- a/cinder/tests/unit/volume/drivers/test_rbd.py +++ b/cinder/tests/unit/volume/drivers/test_rbd.py @@ -14,19 +14,19 @@ # License for the specific language governing permissions and limitations # under the License. +import errno import math import os import tempfile +import time +from unittest import mock +from unittest.mock import call import uuid import castellan import ddt -import errno -import mock -from mock import call from oslo_utils import imageutils from oslo_utils import units -import time from cinder import context from cinder import db diff --git a/cinder/tests/unit/volume/drivers/test_remotefs.py b/cinder/tests/unit/volume/drivers/test_remotefs.py index 3d01f7cf00a..064b36fa85f 100644 --- a/cinder/tests/unit/volume/drivers/test_remotefs.py +++ b/cinder/tests/unit/volume/drivers/test_remotefs.py @@ -17,9 +17,9 @@ import copy import os import re import sys +from unittest import mock import ddt -import mock from cinder import context from cinder import exception diff --git a/cinder/tests/unit/volume/drivers/test_rsd.py b/cinder/tests/unit/volume/drivers/test_rsd.py index dc565448339..3b16d6ee619 100644 --- a/cinder/tests/unit/volume/drivers/test_rsd.py +++ b/cinder/tests/unit/volume/drivers/test_rsd.py @@ -10,9 +10,10 @@ # License for the specific language governing permissions and limitations # under the License. -import fixtures -import mock import sys +from unittest import mock + +import fixtures from cinder import exception from cinder.i18n import _ @@ -70,7 +71,7 @@ fake_sushy.exceptions.InvalidParameterValueError = ( sys.modules['rsd_lib'] = fake_rsd_lib sys.modules['sushy'] = fake_sushy -from cinder.volume.drivers import rsd as rsd_driver +from cinder.volume.drivers import rsd as rsd_driver # noqa class RSDClientTestCase(test.TestCase): diff --git a/cinder/tests/unit/volume/drivers/test_san.py b/cinder/tests/unit/volume/drivers/test_san.py index 447865555a8..6a856fb77e4 100644 --- a/cinder/tests/unit/volume/drivers/test_san.py +++ b/cinder/tests/unit/volume/drivers/test_san.py @@ -13,7 +13,7 @@ # under the License. # -import mock +from unittest import mock from cinder import test from cinder.volume import configuration diff --git a/cinder/tests/unit/volume/drivers/test_seagate.py b/cinder/tests/unit/volume/drivers/test_seagate.py index 726f88d9e3d..5a7f18c81a1 100644 --- a/cinder/tests/unit/volume/drivers/test_seagate.py +++ b/cinder/tests/unit/volume/drivers/test_seagate.py @@ -16,24 +16,21 @@ # """Unit tests for OpenStack Cinder Seagate driver.""" +from unittest import mock + +from defusedxml import lxml as etree +import requests + from cinder import exception -from cinder import test - from cinder.objects import fields - +from cinder import test import cinder.volume.drivers.stx.client import cinder.volume.drivers.stx.common import cinder.volume.drivers.stx.exception as stx_exception import cinder.volume.drivers.stx.fc import cinder.volume.drivers.stx.iscsi - from cinder.zonemanager import utils as fczm_utils -from defusedxml import lxml as etree - -import mock - -import requests STXClient = cinder.volume.drivers.stx.client.STXClient STXCommon = cinder.volume.drivers.stx.common.STXCommon diff --git a/cinder/tests/unit/volume/drivers/test_spdk.py b/cinder/tests/unit/volume/drivers/test_spdk.py index 9ecb2623ecb..a913366ae76 100644 --- a/cinder/tests/unit/volume/drivers/test_spdk.py +++ b/cinder/tests/unit/volume/drivers/test_spdk.py @@ -12,7 +12,7 @@ import copy import json -import mock +from unittest import mock from os_brick import initiator from os_brick.initiator import connector diff --git a/cinder/tests/unit/volume/drivers/test_storpool.py b/cinder/tests/unit/volume/drivers/test_storpool.py index a0797c3d157..b1a2e9a0bb1 100644 --- a/cinder/tests/unit/volume/drivers/test_storpool.py +++ b/cinder/tests/unit/volume/drivers/test_storpool.py @@ -16,9 +16,9 @@ import re import sys +from unittest import mock import ddt -import mock from oslo_utils import units import six diff --git a/cinder/tests/unit/volume/drivers/test_veritas_cnfs.py b/cinder/tests/unit/volume/drivers/test_veritas_cnfs.py index cefd7e15262..7c621b8759d 100644 --- a/cinder/tests/unit/volume/drivers/test_veritas_cnfs.py +++ b/cinder/tests/unit/volume/drivers/test_veritas_cnfs.py @@ -15,8 +15,7 @@ import os - -import mock +from unittest import mock from cinder import context from cinder import exception diff --git a/cinder/tests/unit/volume/drivers/test_vzstorage.py b/cinder/tests/unit/volume/drivers/test_vzstorage.py index ad167c5f1c5..38f9cef5c25 100644 --- a/cinder/tests/unit/volume/drivers/test_vzstorage.py +++ b/cinder/tests/unit/volume/drivers/test_vzstorage.py @@ -14,12 +14,11 @@ import collections import copy -import ddt import errno import os +from unittest import mock -import mock - +import ddt from os_brick.remotefs import remotefs from oslo_utils import units diff --git a/cinder/tests/unit/volume/drivers/test_zadara.py b/cinder/tests/unit/volume/drivers/test_zadara.py index bc4536ac922..1425ece3a45 100644 --- a/cinder/tests/unit/volume/drivers/test_zadara.py +++ b/cinder/tests/unit/volume/drivers/test_zadara.py @@ -16,7 +16,8 @@ Tests for Zadara VPSA volume driver """ import copy -import mock +from unittest import mock + import requests from six.moves.urllib import parse diff --git a/cinder/tests/unit/volume/drivers/veritas_access/test_veritas_iscsi.py b/cinder/tests/unit/volume/drivers/veritas_access/test_veritas_iscsi.py index 121cdd9bd49..9945f42f0ec 100644 --- a/cinder/tests/unit/volume/drivers/veritas_access/test_veritas_iscsi.py +++ b/cinder/tests/unit/volume/drivers/veritas_access/test_veritas_iscsi.py @@ -17,9 +17,9 @@ Unit tests for Veritas Access cinder driver. import hashlib import json import tempfile +from unittest import mock from xml.dom.minidom import Document -import mock from oslo_config import cfg import requests diff --git a/cinder/tests/unit/volume/drivers/vmware/test_fcd.py b/cinder/tests/unit/volume/drivers/vmware/test_fcd.py index c8ba7845bd8..653d6c57a0c 100644 --- a/cinder/tests/unit/volume/drivers/vmware/test_fcd.py +++ b/cinder/tests/unit/volume/drivers/vmware/test_fcd.py @@ -13,12 +13,11 @@ # License for the specific language governing permissions and limitations # under the License. -""" -Test suite for VMware vCenter FCD driver. -""" +"""Test suite for VMware vCenter FCD driver.""" + +from unittest import mock import ddt -import mock from oslo_utils import units from oslo_vmware import image_transfer from oslo_vmware.objects import datastore diff --git a/cinder/tests/unit/volume/drivers/vmware/test_vmware_datastore.py b/cinder/tests/unit/volume/drivers/vmware/test_vmware_datastore.py index 1d3e7187156..017a6b5bde1 100644 --- a/cinder/tests/unit/volume/drivers/vmware/test_vmware_datastore.py +++ b/cinder/tests/unit/volume/drivers/vmware/test_vmware_datastore.py @@ -13,13 +13,11 @@ # License for the specific language governing permissions and limitations # under the License. -""" -Unit tests for datastore module. -""" +"""Unit tests for datastore module.""" import re +from unittest import mock -import mock from oslo_utils import units from cinder import test diff --git a/cinder/tests/unit/volume/drivers/vmware/test_vmware_vmdk.py b/cinder/tests/unit/volume/drivers/vmware/test_vmware_vmdk.py index 0c8d67b72be..93b6ce1a7bb 100644 --- a/cinder/tests/unit/volume/drivers/vmware/test_vmware_vmdk.py +++ b/cinder/tests/unit/volume/drivers/vmware/test_vmware_vmdk.py @@ -13,14 +13,12 @@ # License for the specific language governing permissions and limitations # under the License. -""" -Test suite for VMware vCenter VMDK driver. -""" +"""Test suite for VMware vCenter VMDK driver.""" import re +from unittest import mock import ddt -import mock from oslo_utils import units from oslo_utils import versionutils from oslo_vmware import exceptions diff --git a/cinder/tests/unit/volume/drivers/vmware/test_vmware_volumeops.py b/cinder/tests/unit/volume/drivers/vmware/test_vmware_volumeops.py index 260486de9bb..8d0c8e7f957 100644 --- a/cinder/tests/unit/volume/drivers/vmware/test_vmware_volumeops.py +++ b/cinder/tests/unit/volume/drivers/vmware/test_vmware_volumeops.py @@ -13,12 +13,11 @@ # License for the specific language governing permissions and limitations # under the License. -""" -Test suite for VMware VMDK driver volumeops module. -""" +"""Test suite for VMware VMDK driver volumeops module.""" + +from unittest import mock import ddt -import mock from oslo_utils import units from oslo_vmware import exceptions from oslo_vmware import vim_util diff --git a/cinder/tests/unit/volume/flows/test_create_volume_flow.py b/cinder/tests/unit/volume/flows/test_create_volume_flow.py index 860da11c3dd..f0011f184f2 100644 --- a/cinder/tests/unit/volume/flows/test_create_volume_flow.py +++ b/cinder/tests/unit/volume/flows/test_create_volume_flow.py @@ -14,16 +14,15 @@ # under the License. """ Tests for create_volume TaskFlow """ -import six import sys +from unittest import mock import uuid -import ddt -import mock - from castellan.common import exception as castellan_exc from castellan.tests.unit.key_manager import mock_key_manager +import ddt from oslo_utils import imageutils +import six from cinder import context from cinder import exception diff --git a/cinder/tests/unit/volume/flows/test_manage_snapshot_flow.py b/cinder/tests/unit/volume/flows/test_manage_snapshot_flow.py index 62f04086ec5..501a6a87750 100644 --- a/cinder/tests/unit/volume/flows/test_manage_snapshot_flow.py +++ b/cinder/tests/unit/volume/flows/test_manage_snapshot_flow.py @@ -16,8 +16,9 @@ # TODO(mdovgal): add tests for other TaskFlow cases +from unittest import mock + import ddt -import mock from cinder import context from cinder import exception diff --git a/cinder/tests/unit/volume/flows/test_manage_volume_flow.py b/cinder/tests/unit/volume/flows/test_manage_volume_flow.py index dcf953d4e42..b133e950289 100644 --- a/cinder/tests/unit/volume/flows/test_manage_volume_flow.py +++ b/cinder/tests/unit/volume/flows/test_manage_volume_flow.py @@ -12,7 +12,8 @@ """ Tests for manage_existing TaskFlow """ import inspect -import mock +from unittest import mock + import taskflow.engines from cinder import context diff --git a/cinder/tests/unit/volume/test_availability_zone.py b/cinder/tests/unit/volume/test_availability_zone.py index fb9ceba6357..72f7ebff966 100644 --- a/cinder/tests/unit/volume/test_availability_zone.py +++ b/cinder/tests/unit/volume/test_availability_zone.py @@ -16,7 +16,7 @@ """Test for volume availability zone.""" import datetime -import mock +from unittest import mock from oslo_utils import timeutils diff --git a/cinder/tests/unit/volume/test_capabilities.py b/cinder/tests/unit/volume/test_capabilities.py index 20b78522abe..773ea290972 100644 --- a/cinder/tests/unit/volume/test_capabilities.py +++ b/cinder/tests/unit/volume/test_capabilities.py @@ -14,7 +14,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from oslo_serialization import jsonutils diff --git a/cinder/tests/unit/volume/test_connection.py b/cinder/tests/unit/volume/test_connection.py index b06546f3c8b..420057cf980 100644 --- a/cinder/tests/unit/volume/test_connection.py +++ b/cinder/tests/unit/volume/test_connection.py @@ -15,8 +15,9 @@ # under the License. """Tests for Volume connection test cases.""" +from unittest import mock + import ddt -import mock from cinder import context from cinder import db diff --git a/cinder/tests/unit/volume/test_driver.py b/cinder/tests/unit/volume/test_driver.py index be68f4191e6..0fa50c91fe0 100644 --- a/cinder/tests/unit/volume/test_driver.py +++ b/cinder/tests/unit/volume/test_driver.py @@ -14,11 +14,11 @@ # under the License. """Tests for Volume Code.""" -import ddt -import mock import shutil import tempfile +from unittest import mock +import ddt import os_brick from oslo_config import cfg from oslo_utils import importutils diff --git a/cinder/tests/unit/volume/test_image.py b/cinder/tests/unit/volume/test_image.py index 0570b8a0d53..c60d854da30 100644 --- a/cinder/tests/unit/volume/test_image.py +++ b/cinder/tests/unit/volume/test_image.py @@ -16,9 +16,9 @@ """Tests for volume and images.""" import datetime -import mock import os import tempfile +from unittest import mock from oslo_utils import imageutils from oslo_utils import units diff --git a/cinder/tests/unit/volume/test_init_host.py b/cinder/tests/unit/volume/test_init_host.py index 26e917bc6cd..0e6894e0dab 100644 --- a/cinder/tests/unit/volume/test_init_host.py +++ b/cinder/tests/unit/volume/test_init_host.py @@ -15,7 +15,8 @@ # under the License. """Tests for volume init host method cases.""" -import mock +from unittest import mock + from oslo_config import cfg from oslo_utils import importutils diff --git a/cinder/tests/unit/volume/test_manage_volume.py b/cinder/tests/unit/volume/test_manage_volume.py index 1f7ce854a4e..5d4cc73f1ae 100644 --- a/cinder/tests/unit/volume/test_manage_volume.py +++ b/cinder/tests/unit/volume/test_manage_volume.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from cinder import context from cinder import db diff --git a/cinder/tests/unit/volume/test_replication_manager.py b/cinder/tests/unit/volume/test_replication_manager.py index f9f183d5ac8..cf5263aec04 100644 --- a/cinder/tests/unit/volume/test_replication_manager.py +++ b/cinder/tests/unit/volume/test_replication_manager.py @@ -13,12 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock import uuid import ddt - -import mock - from oslo_config import cfg from oslo_utils import timeutils diff --git a/cinder/tests/unit/volume/test_rpcapi.py b/cinder/tests/unit/volume/test_rpcapi.py index 7075e3eaeed..b50dbba0234 100644 --- a/cinder/tests/unit/volume/test_rpcapi.py +++ b/cinder/tests/unit/volume/test_rpcapi.py @@ -12,12 +12,11 @@ # License for the specific language governing permissions and limitations # under the License. -""" -Unit Tests for cinder.volume.rpcapi -""" -import ddt -import mock +"""Unit Tests for cinder.volume.rpcapi.""" +from unittest import mock + +import ddt from oslo_config import cfg from oslo_serialization import jsonutils diff --git a/cinder/tests/unit/volume/test_snapshot.py b/cinder/tests/unit/volume/test_snapshot.py index 74dcf3b16e9..a1bfeaa1e05 100644 --- a/cinder/tests/unit/volume/test_snapshot.py +++ b/cinder/tests/unit/volume/test_snapshot.py @@ -15,11 +15,11 @@ # under the License. """Tests for global snapshot cases.""" -import ddt import os import sys +from unittest import mock -import mock +import ddt from oslo_config import cfg from oslo_utils import imageutils diff --git a/cinder/tests/unit/volume/test_volume.py b/cinder/tests/unit/volume/test_volume.py index e53441ab707..97ca251c212 100644 --- a/cinder/tests/unit/volume/test_volume.py +++ b/cinder/tests/unit/volume/test_volume.py @@ -16,15 +16,15 @@ """Tests for Volume Code.""" import datetime -import ddt +import enum import time +from unittest import mock import uuid from castellan.common import exception as castellan_exception from castellan import key_manager -import enum +import ddt import eventlet -import mock import os_brick.initiator.connectors.iscsi from oslo_concurrency import processutils from oslo_config import cfg diff --git a/cinder/tests/unit/volume/test_volume_manager.py b/cinder/tests/unit/volume/test_volume_manager.py index c65707b4007..1d0d65d274e 100644 --- a/cinder/tests/unit/volume/test_volume_manager.py +++ b/cinder/tests/unit/volume/test_volume_manager.py @@ -14,7 +14,7 @@ # under the License. """Tests for Volume Manager Code.""" -import mock +from unittest import mock from cinder import exception from cinder.message import message_field diff --git a/cinder/tests/unit/volume/test_volume_migration.py b/cinder/tests/unit/volume/test_volume_migration.py index a2f3ccdca87..bf8c2e7a1ba 100644 --- a/cinder/tests/unit/volume/test_volume_migration.py +++ b/cinder/tests/unit/volume/test_volume_migration.py @@ -15,10 +15,10 @@ # under the License. """Tests for Volume Code.""" -import ddt import time +from unittest import mock -import mock +import ddt import os_brick from oslo_concurrency import processutils from oslo_config import cfg diff --git a/cinder/tests/unit/volume/test_volume_retype.py b/cinder/tests/unit/volume/test_volume_retype.py index 6b019ccfe97..f9abb401ff6 100644 --- a/cinder/tests/unit/volume/test_volume_retype.py +++ b/cinder/tests/unit/volume/test_volume_retype.py @@ -11,7 +11,8 @@ # under the License. """Tests for Volume retype Code.""" -import mock +from unittest import mock + from oslo_config import cfg from cinder import context diff --git a/cinder/tests/unit/windows/test_iscsi.py b/cinder/tests/unit/windows/test_iscsi.py index 3885cb528fb..61d1496cac3 100644 --- a/cinder/tests/unit/windows/test_iscsi.py +++ b/cinder/tests/unit/windows/test_iscsi.py @@ -19,9 +19,9 @@ Unit tests for Windows Server 2012 OpenStack Cinder volume driver """ import os +from unittest import mock import ddt -import mock from oslo_utils import fileutils from oslo_utils import units diff --git a/cinder/tests/unit/windows/test_smbfs.py b/cinder/tests/unit/windows/test_smbfs.py index 302f81f58fa..73e9615f484 100644 --- a/cinder/tests/unit/windows/test_smbfs.py +++ b/cinder/tests/unit/windows/test_smbfs.py @@ -14,9 +14,9 @@ import copy import os +from unittest import mock import ddt -import mock from oslo_utils import units from cinder import context diff --git a/cinder/tests/unit/zonemanager/test_brcd_fc_san_lookup_service.py b/cinder/tests/unit/zonemanager/test_brcd_fc_san_lookup_service.py index 6c915054a4d..0823cba2dc9 100644 --- a/cinder/tests/unit/zonemanager/test_brcd_fc_san_lookup_service.py +++ b/cinder/tests/unit/zonemanager/test_brcd_fc_san_lookup_service.py @@ -16,8 +16,8 @@ """Unit tests for brcd fc san lookup service.""" +from unittest import mock -import mock from oslo_config import cfg from oslo_utils import importutils diff --git a/cinder/tests/unit/zonemanager/test_brcd_fc_zone_client_cli.py b/cinder/tests/unit/zonemanager/test_brcd_fc_zone_client_cli.py index 51ca5cb4734..f721152db9d 100644 --- a/cinder/tests/unit/zonemanager/test_brcd_fc_zone_client_cli.py +++ b/cinder/tests/unit/zonemanager/test_brcd_fc_zone_client_cli.py @@ -16,8 +16,8 @@ """Unit tests for brcd fc zone client cli.""" +from unittest import mock -import mock from oslo_concurrency import processutils from cinder import exception diff --git a/cinder/tests/unit/zonemanager/test_brcd_fc_zone_driver.py b/cinder/tests/unit/zonemanager/test_brcd_fc_zone_driver.py index ea15d5bf61d..14feaa506ef 100644 --- a/cinder/tests/unit/zonemanager/test_brcd_fc_zone_driver.py +++ b/cinder/tests/unit/zonemanager/test_brcd_fc_zone_driver.py @@ -16,8 +16,8 @@ """Unit tests for Brocade fc zone driver.""" +from unittest import mock -import mock from oslo_config import cfg from oslo_utils import importutils import paramiko diff --git a/cinder/tests/unit/zonemanager/test_brcd_http_fc_zone_client.py b/cinder/tests/unit/zonemanager/test_brcd_http_fc_zone_client.py index a9b373854cb..5e9ddcc1821 100644 --- a/cinder/tests/unit/zonemanager/test_brcd_http_fc_zone_client.py +++ b/cinder/tests/unit/zonemanager/test_brcd_http_fc_zone_client.py @@ -16,11 +16,10 @@ """Unit tests for brcd fc zone client http(s).""" import time +from unittest import mock +from unittest.mock import patch from oslo_utils import encodeutils - -import mock -from mock import patch import six from cinder import test diff --git a/cinder/tests/unit/zonemanager/test_cisco_fc_san_lookup_service.py b/cinder/tests/unit/zonemanager/test_cisco_fc_san_lookup_service.py index ac0187a3081..e521f62a253 100644 --- a/cinder/tests/unit/zonemanager/test_cisco_fc_san_lookup_service.py +++ b/cinder/tests/unit/zonemanager/test_cisco_fc_san_lookup_service.py @@ -16,8 +16,8 @@ """Unit tests for Cisco fc san lookup service.""" +from unittest import mock -import mock from oslo_config import cfg from cinder import exception diff --git a/cinder/tests/unit/zonemanager/test_cisco_fc_zone_client_cli.py b/cinder/tests/unit/zonemanager/test_cisco_fc_zone_client_cli.py index 369e7e19250..7288cea2016 100644 --- a/cinder/tests/unit/zonemanager/test_cisco_fc_zone_client_cli.py +++ b/cinder/tests/unit/zonemanager/test_cisco_fc_zone_client_cli.py @@ -18,8 +18,8 @@ """Unit tests for Cisco fc zone client cli.""" import time +from unittest import mock -import mock from oslo_concurrency import processutils from six.moves import range diff --git a/cinder/tests/unit/zonemanager/test_cisco_fc_zone_driver.py b/cinder/tests/unit/zonemanager/test_cisco_fc_zone_driver.py index 5e458a062ff..b41dff5912a 100644 --- a/cinder/tests/unit/zonemanager/test_cisco_fc_zone_driver.py +++ b/cinder/tests/unit/zonemanager/test_cisco_fc_zone_driver.py @@ -16,8 +16,8 @@ """Unit tests for Cisco FC zone driver.""" +from unittest import mock -import mock from oslo_concurrency import processutils from oslo_config import cfg from oslo_utils import importutils diff --git a/cinder/tests/unit/zonemanager/test_driverutils.py b/cinder/tests/unit/zonemanager/test_driverutils.py index bb5d34dcf99..018045e19a7 100644 --- a/cinder/tests/unit/zonemanager/test_driverutils.py +++ b/cinder/tests/unit/zonemanager/test_driverutils.py @@ -14,11 +14,11 @@ # under the License. # - """Unit tests for friendly zone name.""" -import ddt import string +import ddt + from cinder import test from cinder.zonemanager.drivers import driver_utils diff --git a/cinder/tests/unit/zonemanager/test_fc_zone_manager.py b/cinder/tests/unit/zonemanager/test_fc_zone_manager.py index c848d0a3bed..d07ee3c59d2 100644 --- a/cinder/tests/unit/zonemanager/test_fc_zone_manager.py +++ b/cinder/tests/unit/zonemanager/test_fc_zone_manager.py @@ -19,7 +19,7 @@ """Unit tests for FC Zone Manager.""" -import mock +from unittest import mock from cinder import exception from cinder import test diff --git a/cinder/tests/unit/zonemanager/test_volume_driver.py b/cinder/tests/unit/zonemanager/test_volume_driver.py index c97fcf45864..92da76bd5ce 100644 --- a/cinder/tests/unit/zonemanager/test_volume_driver.py +++ b/cinder/tests/unit/zonemanager/test_volume_driver.py @@ -19,7 +19,7 @@ """Unit tests for Volume Manager.""" -import mock +from unittest import mock from cinder import test from cinder.tests import fake_driver diff --git a/cinder/volume/drivers/datera/datera_api2.py b/cinder/volume/drivers/datera/datera_api2.py index 1ed23eddb51..d7d9c243469 100644 --- a/cinder/volume/drivers/datera/datera_api2.py +++ b/cinder/volume/drivers/datera/datera_api2.py @@ -13,22 +13,20 @@ # License for the specific language governing permissions and limitations # under the License. +import ipaddress import re import uuid import eventlet -import ipaddress -import six - from oslo_log import log as logging from oslo_utils import excutils from oslo_utils import units +import six from cinder import exception from cinder.i18n import _ -from cinder.volume import volume_utils - import cinder.volume.drivers.datera.datera_common as datc +from cinder.volume import volume_utils LOG = logging.getLogger(__name__) diff --git a/cinder/volume/drivers/datera/datera_api21.py b/cinder/volume/drivers/datera/datera_api21.py index b4a75d16ef8..eaba6fe34bf 100644 --- a/cinder/volume/drivers/datera/datera_api21.py +++ b/cinder/volume/drivers/datera/datera_api21.py @@ -13,23 +13,21 @@ # License for the specific language governing permissions and limitations # under the License. +import ipaddress import random import re import uuid import eventlet -import ipaddress -import six - from oslo_log import log as logging from oslo_utils import excutils from oslo_utils import units +import six from cinder import exception from cinder.i18n import _ -from cinder.volume import volume_utils - import cinder.volume.drivers.datera.datera_common as datc +from cinder.volume import volume_utils LOG = logging.getLogger(__name__) diff --git a/cinder/volume/drivers/datera/datera_common.py b/cinder/volume/drivers/datera/datera_common.py index 4ae56b8f437..bd008dd3806 100644 --- a/cinder/volume/drivers/datera/datera_common.py +++ b/cinder/volume/drivers/datera/datera_common.py @@ -16,15 +16,14 @@ import functools import json import re -import six import time import types import uuid import eventlet -import requests - from oslo_log import log as logging +import requests +import six from six.moves import http_client from cinder import context diff --git a/cinder/volume/drivers/datera/datera_iscsi.py b/cinder/volume/drivers/datera/datera_iscsi.py index f70034b5d8b..9364a613585 100644 --- a/cinder/volume/drivers/datera/datera_iscsi.py +++ b/cinder/volume/drivers/datera/datera_iscsi.py @@ -25,11 +25,10 @@ from cinder import exception from cinder.i18n import _ from cinder import utils from cinder.volume import configuration -from cinder.volume.drivers.san import san - import cinder.volume.drivers.datera.datera_api2 as api2 import cinder.volume.drivers.datera.datera_api21 as api21 import cinder.volume.drivers.datera.datera_common as datc +from cinder.volume.drivers.san import san LOG = logging.getLogger(__name__) diff --git a/cinder/volume/drivers/dell_emc/powermax/masking.py b/cinder/volume/drivers/dell_emc/powermax/masking.py index cd398e691dc..9e7a486ad72 100644 --- a/cinder/volume/drivers/dell_emc/powermax/masking.py +++ b/cinder/volume/drivers/dell_emc/powermax/masking.py @@ -15,11 +15,11 @@ import ast from copy import deepcopy +import re import sys import time from oslo_log import log as logging -import re import six from cinder import coordination diff --git a/cinder/volume/drivers/dell_emc/powermax/metadata.py b/cinder/volume/drivers/dell_emc/powermax/metadata.py index 98536b9d0f0..c9fc19e7d80 100644 --- a/cinder/volume/drivers/dell_emc/powermax/metadata.py +++ b/cinder/volume/drivers/dell_emc/powermax/metadata.py @@ -14,12 +14,12 @@ # under the License. import datetime import platform -import six import time import traceback import types from oslo_log import log as logging +import six import tabulate from cinder.objects import volume diff --git a/cinder/volume/drivers/dell_emc/powermax/rest.py b/cinder/volume/drivers/dell_emc/powermax/rest.py index 5c860527de1..d25125b4b79 100644 --- a/cinder/volume/drivers/dell_emc/powermax/rest.py +++ b/cinder/volume/drivers/dell_emc/powermax/rest.py @@ -24,7 +24,6 @@ import requests.auth import requests.exceptions as r_exc # pylint: disable=E0401 import requests.packages.urllib3.util.retry as requests_retry - import six from cinder import coordination diff --git a/cinder/volume/drivers/dell_emc/powermax/utils.py b/cinder/volume/drivers/dell_emc/powermax/utils.py index 890ed371fc3..30abcb8c17d 100644 --- a/cinder/volume/drivers/dell_emc/powermax/utils.py +++ b/cinder/volume/drivers/dell_emc/powermax/utils.py @@ -18,7 +18,6 @@ import datetime import hashlib import re -from cinder.objects.group import Group from oslo_log import log as logging from oslo_utils import strutils from oslo_utils import units @@ -27,6 +26,7 @@ import six from cinder import exception from cinder.i18n import _ from cinder.objects import fields +from cinder.objects.group import Group from cinder.volume import volume_types from cinder.volume import volume_utils diff --git a/cinder/volume/drivers/dell_emc/sc/storagecenter_api.py b/cinder/volume/drivers/dell_emc/sc/storagecenter_api.py index 5946dc20a13..e5994b0eabc 100644 --- a/cinder/volume/drivers/dell_emc/sc/storagecenter_api.py +++ b/cinder/volume/drivers/dell_emc/sc/storagecenter_api.py @@ -15,6 +15,7 @@ import json import os.path +import uuid import eventlet from oslo_log import log as logging @@ -22,7 +23,6 @@ from oslo_utils import excutils import requests import six from six.moves import http_client -import uuid from cinder import exception from cinder.i18n import _ diff --git a/cinder/volume/drivers/dell_emc/unity/driver.py b/cinder/volume/drivers/dell_emc/unity/driver.py index aa4239a48f5..38e2f98344f 100644 --- a/cinder/volume/drivers/dell_emc/unity/driver.py +++ b/cinder/volume/drivers/dell_emc/unity/driver.py @@ -17,7 +17,6 @@ from oslo_config import cfg from oslo_log import log as logging - import six from cinder import interface diff --git a/cinder/volume/drivers/dell_emc/vnx/adapter.py b/cinder/volume/drivers/dell_emc/vnx/adapter.py index d6de52008ba..ccb587f8981 100644 --- a/cinder/volume/drivers/dell_emc/vnx/adapter.py +++ b/cinder/volume/drivers/dell_emc/vnx/adapter.py @@ -24,11 +24,9 @@ from oslo_log import log as logging from oslo_utils import importutils import six - from cinder import exception from cinder.i18n import _ from cinder.objects import fields - from cinder.volume.drivers.dell_emc.vnx import client from cinder.volume.drivers.dell_emc.vnx import common from cinder.volume.drivers.dell_emc.vnx import replication diff --git a/cinder/volume/drivers/dell_emc/vnx/taskflows.py b/cinder/volume/drivers/dell_emc/vnx/taskflows.py index bc4dc6e4593..91edb3bc6dc 100644 --- a/cinder/volume/drivers/dell_emc/vnx/taskflows.py +++ b/cinder/volume/drivers/dell_emc/vnx/taskflows.py @@ -15,8 +15,6 @@ from oslo_log import log as logging from oslo_utils import importutils - - import taskflow.engines from taskflow.patterns import linear_flow from taskflow import task diff --git a/cinder/volume/drivers/dell_emc/vnx/utils.py b/cinder/volume/drivers/dell_emc/vnx/utils.py index 3409835db2a..403c3653d96 100644 --- a/cinder/volume/drivers/dell_emc/vnx/utils.py +++ b/cinder/volume/drivers/dell_emc/vnx/utils.py @@ -13,7 +13,6 @@ # License for the specific language governing permissions and limitations # under the License. -import six import time from oslo_log import log as logging @@ -21,6 +20,7 @@ from oslo_service import loopingcall from oslo_utils import excutils from oslo_utils import importutils from oslo_utils import uuidutils +import six from cinder import exception from cinder.i18n import _ diff --git a/cinder/volume/drivers/dell_emc/xtremio.py b/cinder/volume/drivers/dell_emc/xtremio.py index 0d0377bd4dd..c2e47a441c3 100644 --- a/cinder/volume/drivers/dell_emc/xtremio.py +++ b/cinder/volume/drivers/dell_emc/xtremio.py @@ -12,9 +12,9 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -""" -Driver for Dell EMC XtremIO Storage. -supported XtremIO version 2.4 and up +"""Driver for Dell EMC XtremIO Storage. + +Supports XtremIO version 2.4 and up. .. code-block:: none @@ -36,13 +36,13 @@ supported XtremIO version 2.4 and up import json import math import random -import requests import string from oslo_config import cfg from oslo_log import log as logging from oslo_utils import strutils from oslo_utils import units +import requests import six from six.moves import http_client @@ -58,7 +58,6 @@ from cinder.volume.drivers.san import san from cinder.volume import volume_utils from cinder.zonemanager import utils as fczm_utils - LOG = logging.getLogger(__name__) CONF = cfg.CONF diff --git a/cinder/volume/drivers/fujitsu/eternus_dx/eternus_dx_iscsi.py b/cinder/volume/drivers/fujitsu/eternus_dx/eternus_dx_iscsi.py index 27e36d4f2a5..a158a7e98ae 100644 --- a/cinder/volume/drivers/fujitsu/eternus_dx/eternus_dx_iscsi.py +++ b/cinder/volume/drivers/fujitsu/eternus_dx/eternus_dx_iscsi.py @@ -16,15 +16,13 @@ # under the License. # -""" -iSCSI Cinder Volume driver for Fujitsu ETERNUS DX S3 series. -""" +"""iSCSI Cinder Volume driver for Fujitsu ETERNUS DX S3 series.""" +from oslo_log import log as logging import six from cinder import interface from cinder.volume import driver from cinder.volume.drivers.fujitsu.eternus_dx import eternus_dx_common -from oslo_log import log as logging LOG = logging.getLogger(__name__) diff --git a/cinder/volume/drivers/hpe/hpe_3par_common.py b/cinder/volume/drivers/hpe/hpe_3par_common.py index 1d7ad921199..139599ad42f 100644 --- a/cinder/volume/drivers/hpe/hpe_3par_common.py +++ b/cinder/volume/drivers/hpe/hpe_3par_common.py @@ -13,8 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. # -""" -Volume driver common utilities for HPE 3PAR Storage array +"""Volume driver common utilities for HPE 3PAR Storage array. The 3PAR drivers requires 3.1.3 firmware on the 3PAR array. @@ -39,7 +38,6 @@ import json import math import pprint import re -import six import uuid from oslo_config import cfg @@ -49,6 +47,9 @@ from oslo_serialization import base64 from oslo_service import loopingcall from oslo_utils import excutils from oslo_utils import units +import six +import taskflow.engines +from taskflow.patterns import linear_flow from cinder import context from cinder import exception @@ -61,9 +62,6 @@ from cinder.volume import qos_specs from cinder.volume import volume_types from cinder.volume import volume_utils -import taskflow.engines -from taskflow.patterns import linear_flow - try: import hpe3parclient from hpe3parclient import client diff --git a/cinder/volume/drivers/hpe/hpe_lefthand_iscsi.py b/cinder/volume/drivers/hpe/hpe_lefthand_iscsi.py index 4c6ae43d963..dae50f58b97 100644 --- a/cinder/volume/drivers/hpe/hpe_lefthand_iscsi.py +++ b/cinder/volume/drivers/hpe/hpe_lefthand_iscsi.py @@ -34,12 +34,16 @@ LeftHand array. """ +import math +import re + from oslo_config import cfg from oslo_log import log as logging from oslo_serialization import jsonutils as json from oslo_utils import excutils from oslo_utils import importutils from oslo_utils import units +import six from cinder import context from cinder import coordination @@ -54,10 +58,6 @@ from cinder.volume.drivers.san import san from cinder.volume import volume_types from cinder.volume import volume_utils -import math -import re -import six - LOG = logging.getLogger(__name__) hpelefthandclient = importutils.try_import("hpelefthandclient") diff --git a/cinder/volume/drivers/huawei/common.py b/cinder/volume/drivers/huawei/common.py index ac02eb67ff3..68cc74a5fab 100644 --- a/cinder/volume/drivers/huawei/common.py +++ b/cinder/volume/drivers/huawei/common.py @@ -16,13 +16,13 @@ import collections import math import re -import six import uuid from oslo_config import cfg from oslo_log import log as logging from oslo_utils import excutils from oslo_utils import units +import six from cinder import context from cinder import exception diff --git a/cinder/volume/drivers/huawei/huawei_conf.py b/cinder/volume/drivers/huawei/huawei_conf.py index 7ff8091444c..e01932a4b10 100644 --- a/cinder/volume/drivers/huawei/huawei_conf.py +++ b/cinder/volume/drivers/huawei/huawei_conf.py @@ -13,20 +13,19 @@ # License for the specific language governing permissions and limitations # under the License. -""" -Set Huawei private configuration into Configuration object. +"""Sets Huawei private configuration into Configuration object. For conveniently get private configuration. We parse Huawei config file and set every property into Configuration object as an attribute. """ import base64 -from defusedxml import ElementTree as ET import os import re -import six +from defusedxml import ElementTree as ET from oslo_log import log as logging +import six from cinder import exception from cinder.i18n import _ diff --git a/cinder/volume/drivers/huawei/rest_client.py b/cinder/volume/drivers/huawei/rest_client.py index 99b6e66a207..e02b40c1d45 100644 --- a/cinder/volume/drivers/huawei/rest_client.py +++ b/cinder/volume/drivers/huawei/rest_client.py @@ -15,12 +15,12 @@ import json import re -import requests -import six import time from oslo_log import log as logging from oslo_utils import excutils +import requests +import six from cinder import exception from cinder.i18n import _ diff --git a/cinder/volume/drivers/ibm/ibm_storage/ds8k_helper.py b/cinder/volume/drivers/ibm/ibm_storage/ds8k_helper.py index 0ba10006734..871993c7cb8 100644 --- a/cinder/volume/drivers/ibm/ibm_storage/ds8k_helper.py +++ b/cinder/volume/drivers/ibm/ibm_storage/ds8k_helper.py @@ -16,13 +16,13 @@ import collections import copy import distutils.version as dist_version # pylint: disable=E0611 -import eventlet import math import os -import six import string +import eventlet from oslo_log import log as logging +import six from cinder import coordination from cinder import exception diff --git a/cinder/volume/drivers/ibm/ibm_storage/ds8k_proxy.py b/cinder/volume/drivers/ibm/ibm_storage/ds8k_proxy.py index 102e600f89d..4aea35a1a5f 100644 --- a/cinder/volume/drivers/ibm/ibm_storage/ds8k_proxy.py +++ b/cinder/volume/drivers/ibm/ibm_storage/ds8k_proxy.py @@ -13,8 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. # -""" -This is the driver that allows openstack to talk to DS8K. +"""This is the driver that allows openstack to talk to DS8K. All volumes are thin provisioned by default, if the machine is licensed for it. This can be overridden by creating a volume type and specifying a key like so: @@ -62,11 +61,11 @@ Sample settings for cinder.conf: """ import ast import json -import six import eventlet from oslo_config import cfg from oslo_log import log as logging +import six from cinder import context from cinder import coordination diff --git a/cinder/volume/drivers/ibm/ibm_storage/ds8k_replication.py b/cinder/volume/drivers/ibm/ibm_storage/ds8k_replication.py index b556bab33b6..48af7a7bc91 100644 --- a/cinder/volume/drivers/ibm/ibm_storage/ds8k_replication.py +++ b/cinder/volume/drivers/ibm/ibm_storage/ds8k_replication.py @@ -14,10 +14,9 @@ # under the License. # import eventlet -import six - from oslo_log import log as logging from oslo_utils import excutils +import six from cinder import coordination from cinder import exception diff --git a/cinder/volume/drivers/ibm/ibm_storage/ds8k_restclient.py b/cinder/volume/drivers/ibm/ibm_storage/ds8k_restclient.py index 231e9d95e9d..42eec064350 100644 --- a/cinder/volume/drivers/ibm/ibm_storage/ds8k_restclient.py +++ b/cinder/volume/drivers/ibm/ibm_storage/ds8k_restclient.py @@ -14,14 +14,14 @@ # under the License. # import abc -import eventlet import importlib import json -import six -from six.moves import urllib +import eventlet import requests from requests import exceptions as req_exception +import six +from six.moves import urllib from cinder import exception from cinder.i18n import _ diff --git a/cinder/volume/drivers/ibm/ibm_storage/proxy.py b/cinder/volume/drivers/ibm/ibm_storage/proxy.py index 06595cd47a6..9d9f98f28dd 100644 --- a/cinder/volume/drivers/ibm/ibm_storage/proxy.py +++ b/cinder/volume/drivers/ibm/ibm_storage/proxy.py @@ -17,10 +17,10 @@ import functools import gettext import inspect import platform -import six from oslo_log import log as logging from oslo_utils import timeutils +import six from cinder.i18n import _ from cinder import version diff --git a/cinder/volume/drivers/ibm/ibm_storage/xiv_proxy.py b/cinder/volume/drivers/ibm/ibm_storage/xiv_proxy.py index df07fa3510b..bae2e9a3ba7 100644 --- a/cinder/volume/drivers/ibm/ibm_storage/xiv_proxy.py +++ b/cinder/volume/drivers/ibm/ibm_storage/xiv_proxy.py @@ -15,13 +15,10 @@ # import datetime import re -import six import socket - from oslo_log import log as logging from oslo_utils import importutils - pyxcli = importutils.try_import("pyxcli") if pyxcli: from pyxcli import client @@ -29,6 +26,7 @@ if pyxcli: from pyxcli.events import events from pyxcli.mirroring import mirrored_entities from pyxcli import transports +import six from cinder import context from cinder.i18n import _ diff --git a/cinder/volume/drivers/ibm/ibm_storage/xiv_replication.py b/cinder/volume/drivers/ibm/ibm_storage/xiv_replication.py index ad4e3b8d540..e428d69e760 100644 --- a/cinder/volume/drivers/ibm/ibm_storage/xiv_replication.py +++ b/cinder/volume/drivers/ibm/ibm_storage/xiv_replication.py @@ -13,17 +13,16 @@ # License for the specific language governing permissions and limitations # under the License. # -import six from oslo_log import log as logging from oslo_utils import importutils - pyxcli = importutils.try_import("pyxcli") if pyxcli: from pyxcli import errors from pyxcli.mirroring import cg_recovery_manager from pyxcli.mirroring import errors as m_errors from pyxcli.mirroring import volume_recovery_manager +import six from cinder.i18n import _ from cinder.volume.drivers.ibm.ibm_storage import strings diff --git a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py index 8bc19d3ee1e..a9cac09cd77 100644 --- a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py +++ b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py @@ -15,7 +15,6 @@ # import math -import paramiko import random import re import time @@ -31,6 +30,7 @@ from oslo_utils import encodeutils from oslo_utils import excutils from oslo_utils import strutils from oslo_utils import units +import paramiko from retrying import retry import six diff --git a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_iscsi.py b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_iscsi.py index fd2871aeb05..eece51d71b6 100644 --- a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_iscsi.py +++ b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_iscsi.py @@ -14,8 +14,7 @@ # License for the specific language governing permissions and limitations # under the License. # -""" -ISCSI volume driver for IBM Storwize family and SVC storage systems. +"""ISCSI volume driver for IBM Storwize family and SVC storage systems. Notes: 1. If you specify both a password and a key file, this driver will use the @@ -45,7 +44,6 @@ from cinder import exception from cinder.i18n import _ from cinder import interface from cinder.volume import configuration as conf - from cinder.volume.drivers.ibm.storwize_svc import ( storwize_svc_common as storwize_common) diff --git a/cinder/volume/drivers/infinidat.py b/cinder/volume/drivers/infinidat.py index 4d8776a4128..75068a0447e 100644 --- a/cinder/volume/drivers/infinidat.py +++ b/cinder/volume/drivers/infinidat.py @@ -12,16 +12,14 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -""" -INFINIDAT InfiniBox Volume Driver -""" +"""INFINIDAT InfiniBox Volume Driver.""" from contextlib import contextmanager import functools import platform import socket +from unittest import mock -import mock from oslo_config import cfg from oslo_log import log as logging from oslo_utils import units diff --git a/cinder/volume/drivers/inspur/instorage/instorage_iscsi.py b/cinder/volume/drivers/inspur/instorage/instorage_iscsi.py index 88c6bf72589..7928088f407 100644 --- a/cinder/volume/drivers/inspur/instorage/instorage_iscsi.py +++ b/cinder/volume/drivers/inspur/instorage/instorage_iscsi.py @@ -13,8 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. # -""" -ISCSI volume driver for Inspur InStorage family and MCS storage systems. +"""ISCSI volume driver for Inspur InStorage family and MCS storage systems. Notes: 1. Make sure you config the password or key file. If you specify both @@ -53,7 +52,6 @@ from cinder.i18n import _ from cinder import interface from cinder import utils as cinder_utils from cinder.volume import driver - from cinder.volume.drivers.inspur.instorage import instorage_common LOG = logging.getLogger(__name__) diff --git a/cinder/volume/drivers/netapp/dataontap/client/api.py b/cinder/volume/drivers/netapp/dataontap/client/api.py index 4e530dd2e04..8ed2bc1453c 100644 --- a/cinder/volume/drivers/netapp/dataontap/client/api.py +++ b/cinder/volume/drivers/netapp/dataontap/client/api.py @@ -15,19 +15,17 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -""" -NetApp API for Data ONTAP and OnCommand DFM. +"""NetApp API for Data ONTAP and OnCommand DFM. Contains classes required to issue API calls to Data ONTAP and OnCommand DFM. """ +import random from eventlet import greenthread from eventlet import semaphore - from lxml import etree from oslo_log import log as logging from oslo_utils import netutils -import random import six from six.moves import urllib diff --git a/cinder/volume/drivers/netapp/dataontap/client/client_base.py b/cinder/volume/drivers/netapp/dataontap/client/client_base.py index ddc8bd260c3..70dbb5a8f7f 100644 --- a/cinder/volume/drivers/netapp/dataontap/client/client_base.py +++ b/cinder/volume/drivers/netapp/dataontap/client/client_base.py @@ -19,7 +19,6 @@ import sys from oslo_log import log as logging from oslo_utils import excutils - import six from cinder import exception @@ -28,7 +27,6 @@ from cinder import utils from cinder.volume.drivers.netapp.dataontap.client import api as netapp_api from cinder.volume.drivers.netapp import utils as na_utils - LOG = logging.getLogger(__name__) DELETED_PREFIX = 'deleted_cinder_' diff --git a/cinder/volume/drivers/netapp/dataontap/client/client_cmode.py b/cinder/volume/drivers/netapp/dataontap/client/client_cmode.py index 4fd7919783c..a87e1e4f800 100644 --- a/cinder/volume/drivers/netapp/dataontap/client/client_cmode.py +++ b/cinder/volume/drivers/netapp/dataontap/client/client_cmode.py @@ -21,6 +21,7 @@ import math import re from oslo_log import log as logging +from oslo_utils import strutils from oslo_utils import units import six @@ -32,9 +33,6 @@ from cinder.volume.drivers.netapp.dataontap.client import client_base from cinder.volume.drivers.netapp import utils as na_utils from cinder.volume import volume_utils -from oslo_utils import strutils - - LOG = logging.getLogger(__name__) DEFAULT_MAX_PAGE_LENGTH = 50 diff --git a/cinder/volume/drivers/netapp/dataontap/utils/loopingcalls.py b/cinder/volume/drivers/netapp/dataontap/utils/loopingcalls.py index 2037e80aac6..37893aaf21c 100644 --- a/cinder/volume/drivers/netapp/dataontap/utils/loopingcalls.py +++ b/cinder/volume/drivers/netapp/dataontap/utils/loopingcalls.py @@ -11,12 +11,10 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -""" -Collects and starts tasks created from oslo_service.loopingcall. -""" - +"""Collects and starts tasks created from oslo_service.loopingcall.""" from collections import namedtuple + from oslo_service import loopingcall LoopingTask = namedtuple('LoopingTask', diff --git a/cinder/volume/drivers/nexenta/iscsi.py b/cinder/volume/drivers/nexenta/iscsi.py index b1e6ea9a336..33b0d273adb 100644 --- a/cinder/volume/drivers/nexenta/iscsi.py +++ b/cinder/volume/drivers/nexenta/iscsi.py @@ -12,10 +12,9 @@ # License for the specific language governing permissions and limitations # under the License. -import six - from oslo_log import log as logging from oslo_utils import excutils +import six from cinder import exception from cinder.i18n import _ diff --git a/cinder/volume/drivers/nexenta/nfs.py b/cinder/volume/drivers/nexenta/nfs.py index fb8c413e869..f66b0e5ec75 100644 --- a/cinder/volume/drivers/nexenta/nfs.py +++ b/cinder/volume/drivers/nexenta/nfs.py @@ -16,12 +16,12 @@ import hashlib import os import re -import six from eventlet import greenthread from oslo_log import log as logging from oslo_utils import fileutils from oslo_utils import units +import six from cinder import context from cinder import db diff --git a/cinder/volume/drivers/nexenta/utils.py b/cinder/volume/drivers/nexenta/utils.py index 6163ecb1b1c..13ccaef2bc3 100644 --- a/cinder/volume/drivers/nexenta/utils.py +++ b/cinder/volume/drivers/nexenta/utils.py @@ -14,9 +14,9 @@ # under the License. import re -import six from oslo_utils import units +import six import six.moves.urllib.parse as urlparse from cinder import exception diff --git a/cinder/volume/drivers/pure.py b/cinder/volume/drivers/pure.py index f09efe9e606..a8d2969a20e 100644 --- a/cinder/volume/drivers/pure.py +++ b/cinder/volume/drivers/pure.py @@ -12,12 +12,12 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -""" -Volume driver for Pure Storage FlashArray storage system. +"""Volume driver for Pure Storage FlashArray storage system. This driver requires Purity version 4.0.0 or later. """ +from distutils import version import functools import ipaddress import math @@ -25,12 +25,15 @@ import platform import re import uuid -from distutils import version from oslo_config import cfg from oslo_log import log as logging from oslo_utils import excutils from oslo_utils import strutils from oslo_utils import units +try: + from purestorage import purestorage +except ImportError: + purestorage = None import six from cinder import exception @@ -45,11 +48,6 @@ from cinder.volume.drivers.san import san from cinder.volume import volume_utils from cinder.zonemanager import utils as fczm_utils -try: - from purestorage import purestorage -except ImportError: - purestorage = None - LOG = logging.getLogger(__name__) PURE_OPTS = [ diff --git a/cinder/volume/drivers/qnap.py b/cinder/volume/drivers/qnap.py index 228e167dc40..80ddbe2a971 100644 --- a/cinder/volume/drivers/qnap.py +++ b/cinder/volume/drivers/qnap.py @@ -12,19 +12,19 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -""" -Volume driver for QNAP Storage. +"""Volume driver for QNAP Storage. + This driver supports QNAP Storage for iSCSI. """ import base64 from collections import OrderedDict -import eventlet import functools import re import threading import time from defusedxml import cElementTree as ET +import eventlet from oslo_concurrency import lockutils from oslo_config import cfg from oslo_log import log as logging diff --git a/cinder/volume/drivers/quobyte.py b/cinder/volume/drivers/quobyte.py index ede5e3f488d..339619854da 100644 --- a/cinder/volume/drivers/quobyte.py +++ b/cinder/volume/drivers/quobyte.py @@ -16,7 +16,6 @@ import errno import os -import psutil import shutil from oslo_concurrency import processutils @@ -24,6 +23,7 @@ from oslo_config import cfg from oslo_log import log as logging from oslo_utils import fileutils from oslo_utils import fnmatch +import psutil from cinder import compute from cinder import coordination diff --git a/cinder/volume/drivers/rbd.py b/cinder/volume/drivers/rbd.py index 82a9feb6aee..d901710eb33 100644 --- a/cinder/volume/drivers/rbd.py +++ b/cinder/volume/drivers/rbd.py @@ -13,7 +13,6 @@ # under the License. """RADOS Block Device Driver""" -from __future__ import absolute_import import binascii import errno import json @@ -31,6 +30,12 @@ from oslo_utils import encodeutils from oslo_utils import excutils from oslo_utils import fileutils from oslo_utils import units +try: + import rados + import rbd +except ImportError: + rados = None + rbd = None import six from six.moves import urllib @@ -45,14 +50,6 @@ from cinder.volume import configuration from cinder.volume import driver from cinder.volume import volume_utils -try: - import rados - import rbd -except ImportError: - rados = None - rbd = None - - LOG = logging.getLogger(__name__) RBD_OPTS = [ diff --git a/cinder/volume/drivers/rsd.py b/cinder/volume/drivers/rsd.py index 98bf82ec648..cf612b28a83 100644 --- a/cinder/volume/drivers/rsd.py +++ b/cinder/volume/drivers/rsd.py @@ -10,25 +10,14 @@ # License for the specific language governing permissions and limitations # under the License. -""" -Driver for RackScale Design. - -""" +"""Driver for RackScale Design.""" +from distutils import version import json from oslo_config import cfg from oslo_log import log as logging from oslo_utils import units - -from cinder import exception -from cinder.i18n import _ -from cinder import interface -from cinder import utils -from cinder.volume import driver - -from distutils import version - try: from rsd_lib import RSDLib from sushy import exceptions as sushy_exceptions @@ -37,6 +26,12 @@ except ImportError: RSDLib = None sushy_exceptions = None +from cinder import exception +from cinder.i18n import _ +from cinder import interface +from cinder import utils +from cinder.volume import driver + LOG = logging.getLogger(__name__) RSD_OPTS = [ diff --git a/cinder/volume/drivers/stx/client.py b/cinder/volume/drivers/stx/client.py index 6c6aef2f5ce..d8eca8a4f87 100644 --- a/cinder/volume/drivers/stx/client.py +++ b/cinder/volume/drivers/stx/client.py @@ -19,7 +19,6 @@ import hashlib import math import time -from cinder import utils from defusedxml import lxml as etree from oslo_log import log as logging from oslo_utils import strutils @@ -29,6 +28,7 @@ import six from cinder import coordination from cinder.i18n import _ +from cinder import utils import cinder.volume.drivers.stx.exception as stx_exception LOG = logging.getLogger(__name__) diff --git a/cinder/volume/drivers/stx/common.py b/cinder/volume/drivers/stx/common.py index dc8845c4542..a2394b265c2 100644 --- a/cinder/volume/drivers/stx/common.py +++ b/cinder/volume/drivers/stx/common.py @@ -14,16 +14,14 @@ # License for the specific language governing permissions and limitations # under the License. # -""" -Volume driver common utilities for Seagate storage arrays -""" +"""Volume driver common utilities for Seagate storage arrays.""" import base64 -import six import uuid from oslo_config import cfg from oslo_log import log as logging +import six from cinder import exception from cinder.i18n import _ diff --git a/cinder/volume/flows/api/create_volume.py b/cinder/volume/flows/api/create_volume.py index 9415415162f..b3a77b4b104 100644 --- a/cinder/volume/flows/api/create_volume.py +++ b/cinder/volume/flows/api/create_volume.py @@ -11,10 +11,10 @@ # under the License. import collections -import six from oslo_config import cfg from oslo_log import log as logging +import six import taskflow.engines from taskflow.patterns import linear_flow from taskflow.types import failure as ft diff --git a/cinder/volume/manager.py b/cinder/volume/manager.py index 43e8673d8fe..3dad8c0c431 100644 --- a/cinder/volume/manager.py +++ b/cinder/volume/manager.py @@ -35,8 +35,6 @@ intact. """ - -import requests import time from castellan import key_manager @@ -51,6 +49,7 @@ from oslo_utils import timeutils from oslo_utils import units from oslo_utils import uuidutils profiler = importutils.try_import('osprofiler.profiler') +import requests import six from taskflow import exceptions as tfe diff --git a/cinder/volume/volume_utils.py b/cinder/volume/volume_utils.py index cd44511e314..3b7eaec949d 100644 --- a/cinder/volume/volume_utils.py +++ b/cinder/volume/volume_utils.py @@ -14,7 +14,6 @@ """Volume-related Utilities and helpers.""" - import ast import functools import json @@ -22,6 +21,7 @@ import math import operator import os from os import urandom +from random import shuffle import re import socket import tempfile @@ -43,7 +43,6 @@ from oslo_utils import netutils from oslo_utils import strutils from oslo_utils import timeutils from oslo_utils import units -from random import shuffle import six from six.moves import range @@ -59,7 +58,6 @@ from cinder.volume import group_types from cinder.volume import throttling from cinder.volume import volume_types - CONF = cfg.CONF LOG = logging.getLogger(__name__) diff --git a/cinder/wsgi/wsgi.py b/cinder/wsgi/wsgi.py index f15d4060688..1cc69a34fce 100644 --- a/cinder/wsgi/wsgi.py +++ b/cinder/wsgi/wsgi.py @@ -12,21 +12,17 @@ """Cinder OS API WSGI application.""" - import sys import warnings - -from cinder import objects - warnings.simplefilter('once', DeprecationWarning) from oslo_config import cfg from oslo_log import log as logging from oslo_service import wsgi -from cinder import i18n +from cinder import objects # noqa +from cinder import i18n # noqa i18n.enable_lazy() - # Need to register global_opts from cinder.common import config from cinder.common import constants diff --git a/cinder/zonemanager/drivers/brocade/brcd_http_fc_zone_client.py b/cinder/zonemanager/drivers/brocade/brcd_http_fc_zone_client.py index 7dbd0c840ca..fefdbb15272 100644 --- a/cinder/zonemanager/drivers/brocade/brcd_http_fc_zone_client.py +++ b/cinder/zonemanager/drivers/brocade/brcd_http_fc_zone_client.py @@ -18,13 +18,13 @@ Brocade south bound connector to communicate with switch using HTTP or HTTPS protocol. """ -import requests -import six import time from oslo_log import log as logging from oslo_serialization import base64 from oslo_utils import encodeutils +import requests +import six from cinder.i18n import _ from cinder.zonemanager.drivers.brocade import exception as b_exception diff --git a/cinder/zonemanager/drivers/cisco/cisco_fc_zone_driver.py b/cinder/zonemanager/drivers/cisco/cisco_fc_zone_driver.py index afe5585b04f..da8dedf99c2 100644 --- a/cinder/zonemanager/drivers/cisco/cisco_fc_zone_driver.py +++ b/cinder/zonemanager/drivers/cisco/cisco_fc_zone_driver.py @@ -26,15 +26,15 @@ add_connection and delete_connection interfaces. :zone_activate: Used by: class: 'FCZoneDriver'. Defaults to True :zone_name_prefix: Used by: class: 'FCZoneDriver'. Defaults to 'openstack' """ +import re +import string from oslo_concurrency import lockutils from oslo_config import cfg from oslo_log import log as logging from oslo_utils import excutils from oslo_utils import importutils -import re import six -import string from cinder import exception from cinder.i18n import _ diff --git a/lower-constraints.txt b/lower-constraints.txt index 6023c08ad60..35c705e3397 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -32,6 +32,7 @@ extras==1.0.0 fasteners==0.14.1 fixtures==3.0.0 flake8==2.5.5 +flake8-import-order==0.18.1 future==0.16.0 futurist==1.6.0 gitdb2==2.0.3 diff --git a/test-requirements.txt b/test-requirements.txt index 8dcedcdb4cf..d886ac6e389 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -4,11 +4,11 @@ # Install bounded pep8/pyflakes first, then let flake8 install hacking>=2.0.0 # Apache-2.0 +flake8-import-order # LGPLv3 coverage!=4.4,>=4.0 # Apache-2.0 ddt>=1.2.1 # MIT fixtures>=3.0.0 # Apache-2.0/BSD -mock>=2.0.0 # BSD os-api-ref>=1.4.0 # Apache-2.0 oslotest>=3.2.0 # Apache-2.0 pycodestyle==2.5.0 # MIT License diff --git a/tools/config/generate_cinder_opts.py b/tools/config/generate_cinder_opts.py index b0bdfb93645..a372a3e220e 100644 --- a/tools/config/generate_cinder_opts.py +++ b/tools/config/generate_cinder_opts.py @@ -69,7 +69,8 @@ if __name__ == "__main__": # cinder files, otherwise any decorator that uses cinder.objects.YYY will # fail with exception AttributeError: 'module' object has no attribute # 'YYY' when running tox -egenconfig - opt_file.write("from cinder import objects\nobjects.register_all()\n\n") + opt_file.write( + "from cinder import objects # noqa\nobjects.register_all()\n") targetdir = 'cinder' diff --git a/tox.ini b/tox.ini index 0f0106136cd..5aa2a609409 100644 --- a/tox.ini +++ b/tox.ini @@ -192,7 +192,9 @@ ignore = E251,E402,W503,W504,H101 # H904 Delay string interpolations at logging calls. enable-extensions = H106,H203,H904 exclude = .git,.venv,.tox,dist,tools,doc/ext,*egg,build -max-complexity=30 +max-complexity = 30 +application-import-names = cinder +import-order-style = pep8 [hacking] local-check-factory = cinder.tests.hacking.checks.factory