Browse Source

Rename volume/utils.py to volume/volume_utils.py

Much of our code renames this at import already --
just name it "volume_utils" for consistency, and
to make code that imports other modules named "utils"
less confusing.

Change-Id: I3cdf445ac9ab89b3b4c221ed2723835e09d48a53
changes/92/677492/5
Eric Harney 2 years ago
parent
commit
de789648e5
  1. 2
      cinder/api/contrib/services.py
  2. 2
      cinder/api/v2/snapshots.py
  3. 2
      cinder/api/v2/volumes.py
  4. 2
      cinder/api/v3/attachments.py
  5. 2
      cinder/backup/api.py
  6. 2
      cinder/backup/chunkeddriver.py
  7. 2
      cinder/backup/manager.py
  8. 2
      cinder/cmd/manage.py
  9. 18
      cinder/cmd/volume_usage_audit.py
  10. 2
      cinder/db/sqlalchemy/api.py
  11. 2
      cinder/group/api.py
  12. 2
      cinder/image/image_utils.py
  13. 6
      cinder/objects/group.py
  14. 6
      cinder/objects/volume_type.py
  15. 2
      cinder/scheduler/filter_scheduler.py
  16. 2
      cinder/scheduler/filters/instance_locality_filter.py
  17. 2
      cinder/scheduler/host_manager.py
  18. 6
      cinder/service.py
  19. 6
      cinder/test.py
  20. 4
      cinder/tests/fake_driver.py
  21. 2
      cinder/tests/unit/api/v3/test_attachments.py
  22. 36
      cinder/tests/unit/api/v3/test_groups.py
  23. 2
      cinder/tests/unit/backup/drivers/test_backup_google.py
  24. 4
      cinder/tests/unit/backup/drivers/test_backup_nfs.py
  25. 2
      cinder/tests/unit/backup/drivers/test_backup_swift.py
  26. 24
      cinder/tests/unit/backup/test_backup.py
  27. 4
      cinder/tests/unit/backup/test_chunkeddriver.py
  28. 4
      cinder/tests/unit/group/test_groups_manager.py
  29. 4
      cinder/tests/unit/group/test_groups_manager_replication.py
  30. 2
      cinder/tests/unit/scheduler/fakes.py
  31. 2
      cinder/tests/unit/scheduler/test_allocated_capacity_weigher.py
  32. 2
      cinder/tests/unit/scheduler/test_capacity_weigher.py
  33. 2
      cinder/tests/unit/scheduler/test_filter_scheduler.py
  34. 8
      cinder/tests/unit/scheduler/test_volume_number_weigher.py
  35. 2
      cinder/tests/unit/targets/test_scst_driver.py
  36. 2
      cinder/tests/unit/targets/test_tgt_driver.py
  37. 18
      cinder/tests/unit/test_cmd.py
  38. 18
      cinder/tests/unit/test_image_utils.py
  39. 2
      cinder/tests/unit/test_macrosan_drivers.py
  40. 2
      cinder/tests/unit/test_utils.py
  41. 2
      cinder/tests/unit/test_volume_cleanup.py
  42. 22
      cinder/tests/unit/test_volume_transfer.py
  43. 106
      cinder/tests/unit/test_volume_utils.py
  44. 2
      cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_common.py
  45. 2
      cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_fc.py
  46. 2
      cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_iscsi.py
  47. 2
      cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_masking.py
  48. 2
      cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_provision.py
  49. 2
      cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_replication.py
  50. 2
      cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_rest.py
  51. 2
      cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_utils.py
  52. 42
      cinder/tests/unit/volume/drivers/dell_emc/sc/test_sc.py
  53. 2
      cinder/tests/unit/volume/drivers/dell_emc/unity/test_adapter.py
  54. 2
      cinder/tests/unit/volume/drivers/dell_emc/unity/test_driver.py
  55. 3
      cinder/tests/unit/volume/drivers/dell_emc/vxflexos/test_get_manageable.py
  56. 14
      cinder/tests/unit/volume/drivers/dell_emc/vxflexos/test_groups.py
  57. 2
      cinder/tests/unit/volume/drivers/fusionstorage/test_dsware.py
  58. 50
      cinder/tests/unit/volume/drivers/hpe/test_hpe3par.py
  59. 16
      cinder/tests/unit/volume/drivers/hpe/test_hpelefthand.py
  60. 2
      cinder/tests/unit/volume/drivers/huawei/test_huawei_drivers.py
  61. 2
      cinder/tests/unit/volume/drivers/ibm/test_ibm_flashsystem.py
  62. 20
      cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py
  63. 12
      cinder/tests/unit/volume/drivers/ibm/test_xiv_proxy.py
  64. 10
      cinder/tests/unit/volume/drivers/infortrend/test_infortrend_common.py
  65. 2
      cinder/tests/unit/volume/drivers/inspur/as13000/test_as13000_driver.py
  66. 2
      cinder/tests/unit/volume/drivers/inspur/instorage/test_common.py
  67. 4
      cinder/tests/unit/volume/drivers/netapp/dataontap/client/test_client_cmode.py
  68. 2
      cinder/tests/unit/volume/drivers/netapp/dataontap/test_block_base.py
  69. 2
      cinder/tests/unit/volume/drivers/netapp/dataontap/test_block_cmode.py
  70. 2
      cinder/tests/unit/volume/drivers/netapp/dataontap/test_nfs_base.py
  71. 2
      cinder/tests/unit/volume/drivers/netapp/dataontap/test_nfs_cmode.py
  72. 24
      cinder/tests/unit/volume/drivers/solidfire/test_solidfire.py
  73. 30
      cinder/tests/unit/volume/drivers/test_gpfs.py
  74. 44
      cinder/tests/unit/volume/drivers/test_infinidat.py
  75. 2
      cinder/tests/unit/volume/drivers/test_kaminario.py
  76. 12
      cinder/tests/unit/volume/drivers/test_lvm_driver.py
  77. 4
      cinder/tests/unit/volume/drivers/test_nfs.py
  78. 23
      cinder/tests/unit/volume/drivers/test_pure.py
  79. 6
      cinder/tests/unit/volume/drivers/test_rbd.py
  80. 2
      cinder/tests/unit/volume/drivers/test_remotefs.py
  81. 2
      cinder/tests/unit/volume/drivers/test_zfssa.py
  82. 4
      cinder/tests/unit/volume/flows/test_create_volume_flow.py
  83. 2
      cinder/tests/unit/volume/test_connection.py
  84. 4
      cinder/tests/unit/volume/test_driver.py
  85. 2
      cinder/tests/unit/volume/test_init_host.py
  86. 7
      cinder/tests/unit/volume/test_manage_volume.py
  87. 6
      cinder/tests/unit/volume/test_replication_manager.py
  88. 2
      cinder/tests/unit/volume/test_volume.py
  89. 7
      cinder/tests/unit/volume/test_volume_migration.py
  90. 2
      cinder/tests/unit/volume/test_volume_retype.py
  91. 4
      cinder/tests/unit/windows/test_iscsi.py
  92. 2
      cinder/transfer/api.py
  93. 2
      cinder/volume/api.py
  94. 4
      cinder/volume/drivers/datera/datera_api2.py
  95. 4
      cinder/volume/drivers/datera/datera_api21.py
  96. 2
      cinder/volume/drivers/dell_emc/powermax/common.py
  97. 2
      cinder/volume/drivers/dell_emc/powermax/masking.py
  98. 2
      cinder/volume/drivers/dell_emc/powermax/utils.py
  99. 2
      cinder/volume/drivers/dell_emc/sc/storagecenter_common.py
  100. 2
      cinder/volume/drivers/dell_emc/unity/adapter.py

2
cinder/api/contrib/services.py

@ -36,7 +36,7 @@ from cinder.scheduler import rpcapi as scheduler_rpcapi
from cinder import utils
from cinder import volume
from cinder.volume import rpcapi as volume_rpcapi
from cinder.volume import utils as volume_utils
from cinder.volume import volume_utils
CONF = cfg.CONF

2
cinder/api/v2/snapshots.py

@ -27,7 +27,7 @@ from cinder.api.schemas import snapshots as snapshot
from cinder.api import validation
from cinder.api.views import snapshots as snapshot_views
from cinder import volume
from cinder.volume import utils as volume_utils
from cinder.volume import volume_utils
LOG = logging.getLogger(__name__)

2
cinder/api/v2/volumes.py

@ -39,7 +39,7 @@ from cinder.image import glance
from cinder import objects
from cinder import utils
from cinder import volume as cinder_volume
from cinder.volume import utils as volume_utils
from cinder.volume import volume_utils
CONF = cfg.CONF

2
cinder/api/v3/attachments.py

@ -29,7 +29,7 @@ from cinder import objects
from cinder.objects import fields
from cinder.policies import attachments as attachment_policy
from cinder.volume import api as volume_api
from cinder.volume import utils as volume_utils
from cinder.volume import volume_utils
LOG = logging.getLogger(__name__)

2
cinder/backup/api.py

@ -42,7 +42,7 @@ import cinder.policy
from cinder import quota
from cinder import quota_utils
import cinder.volume
from cinder.volume import utils as volume_utils
from cinder.volume import volume_utils
backup_opts = [
cfg.BoolOpt('backup_use_same_host',

2
cinder/backup/chunkeddriver.py

@ -40,7 +40,7 @@ from cinder import exception
from cinder.i18n import _
from cinder import objects
from cinder.objects import fields
from cinder.volume import utils as volume_utils
from cinder.volume import volume_utils
if sys.platform == 'win32':
from os_win import utilsfactory as os_win_utilsfactory

2
cinder/backup/manager.py

@ -58,7 +58,7 @@ from cinder import quota
from cinder import rpc
from cinder import utils
from cinder.volume import rpcapi as volume_rpcapi
from cinder.volume import utils as volume_utils
from cinder.volume import volume_utils
LOG = logging.getLogger(__name__)

2
cinder/cmd/manage.py

@ -85,7 +85,7 @@ from cinder import rpc
from cinder.scheduler import rpcapi as scheduler_rpcapi
from cinder import version
from cinder.volume import rpcapi as volume_rpcapi
from cinder.volume import utils as vutils
from cinder.volume import volume_utils as vutils
CONF = cfg.CONF

18
cinder/cmd/volume_usage_audit.py

@ -51,7 +51,7 @@ from cinder import objects
from cinder import rpc
from cinder import utils
from cinder import version
import cinder.volume.utils
import cinder.volume.volume_utils
CONF = cfg.CONF
@ -99,7 +99,7 @@ def _vol_notify_usage(LOG, volume_ref, extra_info, admin_context):
{'volume_id': volume_ref.id,
'project_id': volume_ref.project_id,
'extra_info': extra_info})
cinder.volume.utils.notify_about_volume_usage(
cinder.volume.volume_utils.notify_about_volume_usage(
admin_context, volume_ref, 'exists', extra_usage_info=extra_info)
except Exception as exc_msg:
LOG.error("Exists volume notification failed: %s",
@ -114,7 +114,7 @@ def _snap_notify_usage(LOG, snapshot_ref, extra_info, admin_context):
{'snapshot_id': snapshot_ref.id,
'project_id': snapshot_ref.project_id,
'extra_info': extra_info})
cinder.volume.utils.notify_about_snapshot_usage(
cinder.volume.volume_utils.notify_about_snapshot_usage(
admin_context, snapshot_ref, 'exists', extra_info)
except Exception as exc_msg:
LOG.error("Exists snapshot notification failed: %s",
@ -124,7 +124,7 @@ def _snap_notify_usage(LOG, snapshot_ref, extra_info, admin_context):
def _backup_notify_usage(LOG, backup_ref, extra_info, admin_context):
"""backup_ref notify usage"""
try:
cinder.volume.utils.notify_about_backup_usage(
cinder.volume.volume_utils.notify_about_backup_usage(
admin_context, backup_ref, 'exists', extra_info)
LOG.debug("Sent notification for <backup_id: %(backup_id)s> "
"<project_id %(project_id)s> <%(extra_info)s>",
@ -221,7 +221,7 @@ def main():
for volume_ref in volumes:
_obj_ref_action(_vol_notify_usage, LOG, volume_ref, extra_info,
admin_context, begin, end,
cinder.volume.utils.notify_about_volume_usage,
cinder.volume.volume_utils.notify_about_volume_usage,
"volume_id", "volume")
snapshots = objects.SnapshotList.get_all_active_by_window(admin_context,
@ -229,8 +229,8 @@ def main():
LOG.info("Found %d snapshots", len(snapshots))
for snapshot_ref in snapshots:
_obj_ref_action(_snap_notify_usage, LOG, snapshot_ref, extra_info,
admin_context, begin,
end, cinder.volume.utils.notify_about_snapshot_usage,
admin_context, begin, end,
cinder.volume.volume_utils.notify_about_snapshot_usage,
"snapshot_id", "snapshot")
backups = objects.BackupList.get_all_active_by_window(admin_context,
@ -239,7 +239,7 @@ def main():
LOG.info("Found %d backups", len(backups))
for backup_ref in backups:
_obj_ref_action(_backup_notify_usage, LOG, backup_ref, extra_info,
admin_context, begin,
end, cinder.volume.utils.notify_about_backup_usage,
admin_context, begin, end,
cinder.volume.volume_utils.notify_about_backup_usage,
"backup_id", "backup")
LOG.info("Volume usage audit completed")

2
cinder/db/sqlalchemy/api.py

@ -66,7 +66,7 @@ from cinder.i18n import _
from cinder import objects
from cinder.objects import fields
from cinder import utils
from cinder.volume import utils as vol_utils
from cinder.volume import volume_utils as vol_utils
CONF = cfg.CONF
LOG = logging.getLogger(__name__)

2
cinder/group/api.py

@ -39,8 +39,8 @@ from cinder import quota_utils
from cinder.scheduler import rpcapi as scheduler_rpcapi
from cinder.volume import api as volume_api
from cinder.volume import rpcapi as volume_rpcapi
from cinder.volume import utils as vol_utils
from cinder.volume import volume_types
from cinder.volume import volume_utils as vol_utils
CONF = cfg.CONF

2
cinder/image/image_utils.py

@ -49,7 +49,7 @@ from cinder import exception
from cinder.i18n import _
from cinder import utils
from cinder.volume import throttling
from cinder.volume import utils as volume_utils
from cinder.volume import volume_utils
LOG = logging.getLogger(__name__)

6
cinder/objects/group.py

@ -21,7 +21,7 @@ from cinder.i18n import _
from cinder import objects
from cinder.objects import base
from cinder.objects import fields as c_fields
from cinder.volume import utils as vol_utils
from cinder.volume import volume_utils
@base.CinderObjectRegistry.register
@ -180,8 +180,8 @@ class Group(base.CinderPersistentObject, base.CinderObject,
@property
def is_replicated(self):
if (vol_utils.is_group_a_type(self, "group_replication_enabled") or
vol_utils.is_group_a_type(
if (volume_utils.is_group_a_type(self, "group_replication_enabled") or
volume_utils.is_group_a_type(
self, "consistent_group_replication_enabled")):
return True
return False

6
cinder/objects/volume_type.py

@ -21,8 +21,8 @@ from cinder import exception
from cinder.i18n import _
from cinder import objects
from cinder.objects import base
from cinder.volume import utils
from cinder.volume import volume_types
from cinder.volume import volume_utils
@base.CinderObjectRegistry.register
@ -163,10 +163,10 @@ class VolumeType(base.CinderPersistentObject, base.CinderObject,
orm_obj, expected_attrs=expected_attrs)
def is_replicated(self):
return utils.is_replicated_spec(self.extra_specs)
return volume_utils.is_replicated_spec(self.extra_specs)
def is_multiattach(self):
return utils.is_multiattach_spec(self.extra_specs)
return volume_utils.is_multiattach_spec(self.extra_specs)
@base.CinderObjectRegistry.register

2
cinder/scheduler/filter_scheduler.py

@ -28,7 +28,7 @@ from cinder import exception
from cinder.i18n import _
from cinder.scheduler import driver
from cinder.scheduler import scheduler_options
from cinder.volume import utils
from cinder.volume import volume_utils as utils
CONF = cfg.CONF
LOG = logging.getLogger(__name__)

2
cinder/scheduler/filters/instance_locality_filter.py

@ -20,7 +20,7 @@ from cinder.compute import nova
from cinder import exception
from cinder.i18n import _
from cinder.scheduler import filters
from cinder.volume import utils as volume_utils
from cinder.volume import volume_utils
LOG = logging.getLogger(__name__)

2
cinder/scheduler/host_manager.py

@ -34,8 +34,8 @@ from cinder import exception
from cinder import objects
from cinder.scheduler import filters
from cinder import utils
from cinder.volume import utils as vol_utils
from cinder.volume import volume_types
from cinder.volume import volume_utils as vol_utils
# FIXME: This file should be renamed to backend_manager, we should also rename

6
cinder/service.py

@ -48,7 +48,7 @@ from cinder.objects import base as objects_base
from cinder.objects import fields
from cinder import rpc
from cinder import version
from cinder.volume import utils as vol_utils
from cinder.volume import volume_utils
if os.name == 'nt':
from os_win import utilsfactory as os_win_utilsfactory
@ -250,7 +250,7 @@ class Service(service.Service):
target = messaging.Target(
topic='%(topic)s.%(host)s' % {'topic': self.topic,
'host': self.host},
server=vol_utils.extract_host(self.host, 'host'))
server=volume_utils.extract_host(self.host, 'host'))
self.backend_rpcserver = rpc.get_server(target, endpoints,
serializer)
self.backend_rpcserver.start()
@ -262,7 +262,7 @@ class Service(service.Service):
'cluster': self.cluster})
target = messaging.Target(
topic='%s.%s' % (self.topic, self.cluster),
server=vol_utils.extract_host(self.cluster, 'host'))
server=volume_utils.extract_host(self.cluster, 'host'))
serializer = objects_base.CinderObjectSerializer(obj_version_cap)
self.cluster_rpcserver = rpc.get_server(target, endpoints,
serializer)

6
cinder/test.py

@ -55,7 +55,7 @@ from cinder import service
from cinder.tests import fixtures as cinder_fixtures
from cinder.tests.unit import conf_fixture
from cinder.tests.unit import fake_notifier
from cinder.volume import utils
from cinder.volume import volume_utils
CONF = config.CONF
@ -540,8 +540,8 @@ class RPCAPITestCase(TestCase, ModelsObjectComparatorMixin):
version = version or self.base_version
topic = None
if server is not None:
backend = utils.extract_host(server)
server = utils.extract_host(server, 'host')
backend = volume_utils.extract_host(server)
server = volume_utils.extract_host(server, 'host')
topic = 'cinder-volume.%s' % backend
if expected_method is None:

4
cinder/tests/fake_driver.py

@ -21,7 +21,7 @@ from cinder.tests.unit.brick import fake_lvm
from cinder import utils
from cinder.volume import driver
from cinder.volume.drivers import lvm
from cinder.volume import utils as vol_utils
from cinder.volume import volume_utils
from cinder.zonemanager import utils as fczm_utils
@ -50,7 +50,7 @@ class FakeLoggingVolumeDriver(lvm.LVMVolumeDriver):
model_update = {}
try:
if (volume.volume_type and volume.volume_type.extra_specs and
vol_utils.is_replicated_spec(
volume_utils.is_replicated_spec(
volume.volume_type.extra_specs)):
# Sets the new volume's replication_status to disabled
model_update['replication_status'] = (

2
cinder/tests/unit/api/v3/test_attachments.py

@ -34,7 +34,7 @@ from cinder.tests.unit.api import fakes
from cinder.tests.unit import fake_constants as fake
from cinder.volume import api as volume_api
from cinder.volume import rpcapi as volume_rpcapi
from cinder.volume import utils as volume_utils
from cinder.volume import volume_utils
@ddt.ddt

36
cinder/tests/unit/api/v3/test_groups.py

@ -1176,9 +1176,9 @@ class GroupsAPITestCase(test.TestCase):
volume.destroy()
source_grp.destroy()
@mock.patch('cinder.volume.utils.is_replicated_spec',
@mock.patch('cinder.volume.volume_utils.is_replicated_spec',
return_value=True)
@mock.patch('cinder.volume.utils.is_group_a_type',
@mock.patch('cinder.volume.volume_utils.is_group_a_type',
return_value=True)
def test_enable_replication(self, mock_rep_grp_type, mock_rep_vol_type):
req = fakes.HTTPRequest.blank('/v3/%s/groups/%s/action' %
@ -1199,8 +1199,8 @@ class GroupsAPITestCase(test.TestCase):
@ddt.data((True, False), (False, True), (False, False))
@ddt.unpack
@mock.patch('cinder.volume.utils.is_replicated_spec')
@mock.patch('cinder.volume.utils.is_group_a_type')
@mock.patch('cinder.volume.volume_utils.is_replicated_spec')
@mock.patch('cinder.volume.volume_utils.is_group_a_type')
def test_enable_replication_wrong_type(self, is_grp_rep_type,
is_vol_rep_type,
mock_rep_grp_type,
@ -1217,9 +1217,9 @@ class GroupsAPITestCase(test.TestCase):
self.controller.enable_replication,
req, self.group3.id, body=body)
@mock.patch('cinder.volume.utils.is_replicated_spec',
@mock.patch('cinder.volume.volume_utils.is_replicated_spec',
return_value=False)
@mock.patch('cinder.volume.utils.is_group_a_type',
@mock.patch('cinder.volume.volume_utils.is_group_a_type',
return_value=True)
def test_enable_replication_wrong_group_type(self, mock_rep_grp_type,
mock_rep_vol_type):
@ -1233,9 +1233,9 @@ class GroupsAPITestCase(test.TestCase):
self.controller.enable_replication,
req, self.group3.id, body=body)
@mock.patch('cinder.volume.utils.is_replicated_spec',
@mock.patch('cinder.volume.volume_utils.is_replicated_spec',
return_value=True)
@mock.patch('cinder.volume.utils.is_group_a_type',
@mock.patch('cinder.volume.volume_utils.is_group_a_type',
return_value=True)
@ddt.data((mv.GROUP_REPLICATION, True,
fields.GroupStatus.CREATING,
@ -1266,9 +1266,9 @@ class GroupsAPITestCase(test.TestCase):
self.controller.enable_replication,
req, group_id, body=body)
@mock.patch('cinder.volume.utils.is_replicated_spec',
@mock.patch('cinder.volume.volume_utils.is_replicated_spec',
return_value=True)
@mock.patch('cinder.volume.utils.is_group_a_type',
@mock.patch('cinder.volume.volume_utils.is_group_a_type',
return_value=True)
def test_disable_replication(self, mock_rep_grp_type, mock_rep_vol_type):
req = fakes.HTTPRequest.blank('/v3/%s/groups/%s/action' %
@ -1288,9 +1288,9 @@ class GroupsAPITestCase(test.TestCase):
self.assertEqual(fields.ReplicationStatus.DISABLING,
group.replication_status)
@mock.patch('cinder.volume.utils.is_replicated_spec',
@mock.patch('cinder.volume.volume_utils.is_replicated_spec',
return_value=True)
@mock.patch('cinder.volume.utils.is_group_a_type',
@mock.patch('cinder.volume.volume_utils.is_group_a_type',
return_value=True)
@ddt.data((mv.GROUP_REPLICATION, True,
fields.GroupStatus.CREATING,
@ -1330,9 +1330,9 @@ class GroupsAPITestCase(test.TestCase):
self.controller.disable_replication,
req, group_id, body=body)
@mock.patch('cinder.volume.utils.is_replicated_spec',
@mock.patch('cinder.volume.volume_utils.is_replicated_spec',
return_value=True)
@mock.patch('cinder.volume.utils.is_group_a_type',
@mock.patch('cinder.volume.volume_utils.is_group_a_type',
return_value=True)
def test_failover_replication(self, mock_rep_grp_type, mock_rep_vol_type):
req = fakes.HTTPRequest.blank('/v3/%s/groups/%s/action' %
@ -1352,9 +1352,9 @@ class GroupsAPITestCase(test.TestCase):
self.assertEqual(fields.ReplicationStatus.FAILING_OVER,
group.replication_status)
@mock.patch('cinder.volume.utils.is_replicated_spec',
@mock.patch('cinder.volume.volume_utils.is_replicated_spec',
return_value=True)
@mock.patch('cinder.volume.utils.is_group_a_type',
@mock.patch('cinder.volume.volume_utils.is_group_a_type',
return_value=True)
@ddt.data((mv.GROUP_REPLICATION, True,
fields.GroupStatus.CREATING,
@ -1394,9 +1394,9 @@ class GroupsAPITestCase(test.TestCase):
self.controller.failover_replication,
req, group_id, body=body)
@mock.patch('cinder.volume.utils.is_replicated_spec',
@mock.patch('cinder.volume.volume_utils.is_replicated_spec',
return_value=True)
@mock.patch('cinder.volume.utils.is_group_a_type',
@mock.patch('cinder.volume.volume_utils.is_group_a_type',
return_value=True)
@mock.patch('cinder.volume.rpcapi.VolumeAPI.list_replication_targets')
def test_list_replication_targets(self, mock_list_rep_targets,

2
cinder/tests/unit/backup/drivers/test_backup_google.py

@ -180,7 +180,7 @@ class GoogleBackupDriverTestCase(test.TestCase):
# Note(yikun): It mocks out the backup notifier to avoid to leak
# notifications into other test.
notify_patcher = mock.patch(
'cinder.volume.utils.notify_about_backup_usage')
'cinder.volume.volume_utils.notify_about_backup_usage')
notify_patcher.start()
self.addCleanup(notify_patcher.stop)

4
cinder/tests/unit/backup/drivers/test_backup_nfs.py

@ -71,7 +71,7 @@ class BackupNFSShareTestCase(test.TestCase):
# Note(yikun): It mocks out the backup notifier to avoid to leak
# notifications into other test.
notify_patcher = mock.patch(
'cinder.volume.utils.notify_about_backup_usage')
'cinder.volume.volume_utils.notify_about_backup_usage')
notify_patcher.start()
self.addCleanup(notify_patcher.stop)
@ -257,7 +257,7 @@ class BackupNFSTestCase(test.TestCase):
# Note(yikun): It mocks out the backup notifier to avoid to leak
# notifications into other test.
notify_patcher = mock.patch(
'cinder.volume.utils.notify_about_backup_usage')
'cinder.volume.volume_utils.notify_about_backup_usage')
notify_patcher.start()
self.addCleanup(notify_patcher.stop)

2
cinder/tests/unit/backup/drivers/test_backup_swift.py

@ -126,7 +126,7 @@ class BackupSwiftTestCase(test.TestCase):
self.size_volume_file += 1024
notify_patcher = mock.patch(
'cinder.volume.utils.notify_about_backup_usage')
'cinder.volume.volume_utils.notify_about_backup_usage')
notify_patcher.start()
self.addCleanup(notify_patcher.stop)

24
cinder/tests/unit/backup/test_backup.py

@ -1009,7 +1009,7 @@ class BackupTestCase(BaseBackupTest):
self.assertEqual('available', temp_vol['status'])
self.assertEqual('fake_provider_id', temp_vol['provider_id'])
@mock.patch('cinder.volume.utils.notify_about_backup_usage')
@mock.patch('cinder.volume.volume_utils.notify_about_backup_usage')
def test_create_backup_with_notify(self, notify):
"""Test normal backup creation with notifications."""
vol_size = 1
@ -1021,7 +1021,7 @@ class BackupTestCase(BaseBackupTest):
self.assertEqual(2, notify.call_count)
@mock.patch('cinder.volume.rpcapi.VolumeAPI.get_backup_device')
@mock.patch('cinder.volume.utils.clone_encryption_key')
@mock.patch('cinder.volume.volume_utils.clone_encryption_key')
@mock.patch('cinder.utils.brick_get_connector_properties')
def test_create_backup_encrypted_volume(self,
mock_connector_properties,
@ -1049,7 +1049,7 @@ class BackupTestCase(BaseBackupTest):
self.assertEqual(fake.UUID2, backup.encryption_key_id)
@mock.patch('cinder.volume.rpcapi.VolumeAPI.get_backup_device')
@mock.patch('cinder.volume.utils.clone_encryption_key')
@mock.patch('cinder.volume.volume_utils.clone_encryption_key')
@mock.patch('cinder.utils.brick_get_connector_properties')
def test_create_backup_encrypted_volume_again(self,
mock_connector_properties,
@ -1262,7 +1262,7 @@ class BackupTestCase(BaseBackupTest):
backup = db.backup_get(self.ctxt, backup.id)
self.assertEqual(fields.BackupStatus.AVAILABLE, backup['status'])
@mock.patch('cinder.volume.utils.notify_about_backup_usage')
@mock.patch('cinder.volume.volume_utils.notify_about_backup_usage')
def test_restore_backup_with_notify(self, notify):
"""Test normal backup restoration with notifications."""
vol_size = 1
@ -1275,8 +1275,8 @@ class BackupTestCase(BaseBackupTest):
self.backup_mgr.restore_backup(self.ctxt, backup, vol_id)
self.assertEqual(2, notify.call_count)
@mock.patch('cinder.volume.utils.clone_encryption_key')
@mock.patch('cinder.volume.utils.delete_encryption_key')
@mock.patch('cinder.volume.volume_utils.clone_encryption_key')
@mock.patch('cinder.volume.volume_utils.delete_encryption_key')
@mock.patch(
'cinder.tests.unit.backup.fake_service.FakeBackupService.restore')
@mock.patch('cinder.utils.brick_get_connector_properties')
@ -1308,8 +1308,8 @@ class BackupTestCase(BaseBackupTest):
mock_clone_encryption_key.assert_not_called()
mock_delete_encryption_key.assert_not_called()
@mock.patch('cinder.volume.utils.clone_encryption_key')
@mock.patch('cinder.volume.utils.delete_encryption_key')
@mock.patch('cinder.volume.volume_utils.clone_encryption_key')
@mock.patch('cinder.volume.volume_utils.delete_encryption_key')
@mock.patch(
'cinder.tests.unit.backup.fake_service.FakeBackupService.restore')
@mock.patch('cinder.utils.brick_get_connector_properties')
@ -1369,8 +1369,8 @@ class BackupTestCase(BaseBackupTest):
backup = db.backup_get(self.ctxt, backup.id)
self.assertEqual(fake.UUID2, backup.encryption_key_id)
@mock.patch('cinder.volume.utils.clone_encryption_key')
@mock.patch('cinder.volume.utils.delete_encryption_key')
@mock.patch('cinder.volume.volume_utils.clone_encryption_key')
@mock.patch('cinder.volume.volume_utils.delete_encryption_key')
@mock.patch(
'cinder.tests.unit.backup.fake_service.FakeBackupService.restore')
@mock.patch('cinder.utils.brick_get_connector_properties')
@ -1506,7 +1506,7 @@ class BackupTestCase(BaseBackupTest):
self.assertGreaterEqual(timeutils.utcnow(), backup.deleted_at)
self.assertEqual(fields.BackupStatus.DELETED, backup.status)
@mock.patch('cinder.volume.utils.delete_encryption_key')
@mock.patch('cinder.volume.volume_utils.delete_encryption_key')
def test_delete_backup_of_encrypted_volume(self,
mock_delete_encryption_key):
"""Test deletion of backup of encrypted volume"""
@ -1525,7 +1525,7 @@ class BackupTestCase(BaseBackupTest):
self.assertTrue(backup.deleted)
self.assertIsNone(backup.encryption_key_id)
@mock.patch('cinder.volume.utils.notify_about_backup_usage')
@mock.patch('cinder.volume.volume_utils.notify_about_backup_usage')
def test_delete_backup_with_notify(self, notify):
"""Test normal backup deletion with notifications."""
vol_id = self._create_volume_db_entry(size=1)

4
cinder/tests/unit/backup/test_chunkeddriver.py

@ -415,7 +415,7 @@ class ChunkedDriverTestCase(test.TestCase):
metadata['volume-base-metadata']['display_name'])
self.assertEqual('testhost', metadata['volume-base-metadata']['host'])
@mock.patch('cinder.volume.utils.notify_about_backup_usage')
@mock.patch('cinder.volume.volume_utils.notify_about_backup_usage')
def test_send_progress_end(self, mock_notify):
obj_meta = {}
self.driver._send_progress_end(self.ctxt, self.backup, obj_meta)
@ -423,7 +423,7 @@ class ChunkedDriverTestCase(test.TestCase):
self.assertEqual(100, obj_meta.get('backup_percent', 0))
self.assertTrue(mock_notify.called)
@mock.patch('cinder.volume.utils.notify_about_backup_usage')
@mock.patch('cinder.volume.volume_utils.notify_about_backup_usage')
def test_send_progress_notification(self, mock_notify):
obj_meta = {}
self.driver._send_progress_notification(

4
cinder/tests/unit/group/test_groups_manager.py

@ -35,7 +35,7 @@ from cinder.tests.unit import utils as tests_utils
from cinder.volume import api as volume_api
from cinder.volume import configuration as conf
from cinder.volume import driver
from cinder.volume import utils as volutils
from cinder.volume import volume_utils
GROUP_QUOTAS = quota.GROUP_QUOTAS
CONF = cfg.CONF
@ -148,7 +148,7 @@ class GroupManagerTestCase(test.TestCase):
"""Make sure that the pool is part of the host."""
self.assertIn('host', group)
host = group.host
pool = volutils.extract_host(host, level='pool')
pool = volume_utils.extract_host(host, level='pool')
self.assertEqual('fakepool', pool)
return {'status': fields.GroupStatus.AVAILABLE}

4
cinder/tests/unit/group/test_groups_manager_replication.py

@ -29,7 +29,7 @@ from cinder.tests.unit import utils as tests_utils
from cinder.volume import api as volume_api
from cinder.volume import configuration as conf
from cinder.volume import driver
from cinder.volume import utils as volutils
from cinder.volume import volume_utils
GROUP_QUOTAS = quota.GROUP_QUOTAS
CONF = cfg.CONF
@ -77,7 +77,7 @@ class GroupManagerTestCase(test.TestCase):
"""Make sure that the pool is part of the host."""
self.assertIn('host', group)
host = group.host
pool = volutils.extract_host(host, level='pool')
pool = volume_utils.extract_host(host, level='pool')
self.assertEqual('fakepool', pool)
return {'status': fields.GroupStatus.AVAILABLE,
'replication_status': fields.ReplicationStatus.DISABLING}

2
cinder/tests/unit/scheduler/fakes.py

@ -22,7 +22,7 @@ from oslo_utils import uuidutils
from cinder.scheduler import filter_scheduler
from cinder.scheduler import host_manager
from cinder.volume import utils
from cinder.volume import volume_utils as utils
UTC_NOW = timeutils.utcnow()

2
cinder/tests/unit/scheduler/test_allocated_capacity_weigher.py

@ -24,7 +24,7 @@ from cinder import context
from cinder.scheduler import weights
from cinder import test
from cinder.tests.unit.scheduler import fakes
from cinder.volume import utils
from cinder.volume import volume_utils as utils
class AllocatedCapacityWeigherTestCase(test.TestCase):

2
cinder/tests/unit/scheduler/test_capacity_weigher.py

@ -25,7 +25,7 @@ from cinder import context
from cinder.scheduler import weights
from cinder import test
from cinder.tests.unit.scheduler import fakes
from cinder.volume import utils
from cinder.volume import volume_utils as utils
@ddt.ddt

2
cinder/tests/unit/scheduler/test_filter_scheduler.py

@ -27,7 +27,7 @@ from cinder.scheduler import host_manager
from cinder.tests.unit import fake_constants as fake
from cinder.tests.unit.scheduler import fakes
from cinder.tests.unit.scheduler import test_scheduler
from cinder.volume import utils
from cinder.volume import volume_utils as utils
@ddt.ddt

8
cinder/tests/unit/scheduler/test_volume_number_weigher.py

@ -25,11 +25,11 @@ from cinder.scheduler import weights
from cinder import test
from cinder.tests.unit import fake_constants
from cinder.tests.unit.scheduler import fakes
from cinder.volume import utils
from cinder.volume import volume_utils
def fake_volume_data_get_for_host(context, host, count_only=False):
host = utils.extract_host(host)
host = volume_utils.extract_host(host)
if host == 'host1':
return 1
elif host == 'host2':
@ -96,7 +96,7 @@ class VolumeNumberWeigherTestCase(test.TestCase):
weighed_host = self._get_weighed_host(backend_info_list)
self.assertEqual(0.0, weighed_host.weight)
self.assertEqual('host1',
utils.extract_host(weighed_host.obj.host))
volume_utils.extract_host(weighed_host.obj.host))
def test_volume_number_weight_multiplier2(self):
self.flags(volume_number_multiplier=1.0)
@ -113,4 +113,4 @@ class VolumeNumberWeigherTestCase(test.TestCase):
weighed_host = self._get_weighed_host(backend_info_list)
self.assertEqual(1.0, weighed_host.weight)
self.assertEqual('host5',
utils.extract_host(weighed_host.obj.host))
volume_utils.extract_host(weighed_host.obj.host))

2
cinder/tests/unit/targets/test_scst_driver.py

@ -16,7 +16,7 @@ from cinder import context
from cinder.tests.unit.targets import targets_fixture as tf
from cinder import utils
from cinder.volume.targets import scst
from cinder.volume import utils as vutils
from cinder.volume import volume_utils as vutils
class TestSCSTAdmDriver(tf.TargetDriverFixture):

2
cinder/tests/unit/targets/test_tgt_driver.py

@ -23,7 +23,7 @@ from cinder import test
from cinder.tests.unit.targets import targets_fixture as tf
from cinder import utils
from cinder.volume.targets import tgt
from cinder.volume import utils as vutils
from cinder.volume import volume_utils as vutils
class TestTgtAdmDriver(tf.TargetDriverFixture):

18
cinder/tests/unit/test_cmd.py

@ -1800,7 +1800,7 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
rpc_init.assert_called_once_with(CONF)
last_completed_audit_period.assert_called_once_with()
@mock.patch('cinder.volume.utils.notify_about_volume_usage')
@mock.patch('cinder.volume.volume_utils.notify_about_volume_usage')
@mock.patch('cinder.objects.volume.VolumeList.get_all_active_by_window')
@mock.patch('cinder.utils.last_completed_audit_period')
@mock.patch('cinder.rpc.init')
@ -1866,7 +1866,7 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
extra_usage_info=local_extra_info)
])
@mock.patch('cinder.volume.utils.notify_about_volume_usage')
@mock.patch('cinder.volume.volume_utils.notify_about_volume_usage')
@mock.patch('cinder.objects.volume.VolumeList.get_all_active_by_window')
@mock.patch('cinder.utils.last_completed_audit_period')
@mock.patch('cinder.rpc.init')
@ -1940,10 +1940,10 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
extra_usage_info=local_extra_info_delete)
])
@mock.patch('cinder.volume.utils.notify_about_snapshot_usage')
@mock.patch('cinder.volume.volume_utils.notify_about_snapshot_usage')
@mock.patch('cinder.objects.snapshot.SnapshotList.'
'get_all_active_by_window')
@mock.patch('cinder.volume.utils.notify_about_volume_usage')
@mock.patch('cinder.volume.volume_utils.notify_about_volume_usage')
@mock.patch('cinder.objects.volume.VolumeList.get_all_active_by_window')
@mock.patch('cinder.utils.last_completed_audit_period')
@mock.patch('cinder.rpc.init')
@ -2017,9 +2017,9 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
extra_usage_info=local_extra_info_delete)
])
@mock.patch('cinder.volume.utils.notify_about_backup_usage')
@mock.patch('cinder.volume.volume_utils.notify_about_backup_usage')
@mock.patch('cinder.objects.backup.BackupList.get_all_active_by_window')
@mock.patch('cinder.volume.utils.notify_about_volume_usage')
@mock.patch('cinder.volume.volume_utils.notify_about_volume_usage')
@mock.patch('cinder.objects.volume.VolumeList.get_all_active_by_window')
@mock.patch('cinder.utils.last_completed_audit_period')
@mock.patch('cinder.rpc.init')
@ -2084,12 +2084,12 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
ctxt, backup1, 'delete.start',
extra_usage_info=local_extra_info_delete)
@mock.patch('cinder.volume.utils.notify_about_backup_usage')
@mock.patch('cinder.volume.volume_utils.notify_about_backup_usage')
@mock.patch('cinder.objects.backup.BackupList.get_all_active_by_window')
@mock.patch('cinder.volume.utils.notify_about_snapshot_usage')
@mock.patch('cinder.volume.volume_utils.notify_about_snapshot_usage')
@mock.patch('cinder.objects.snapshot.SnapshotList.'
'get_all_active_by_window')
@mock.patch('cinder.volume.utils.notify_about_volume_usage')
@mock.patch('cinder.volume.volume_utils.notify_about_volume_usage')
@mock.patch('cinder.objects.volume.VolumeList.get_all_active_by_window')
@mock.patch('cinder.utils.last_completed_audit_period')
@mock.patch('cinder.rpc.init')

18
cinder/tests/unit/test_image_utils.py

@ -137,7 +137,7 @@ class TestConvertImage(test.TestCase):
mock_info.return_value.virtual_size = 1048576
throttle = throttling.Throttle(prefix=['cgcmd'])
with mock.patch('cinder.volume.utils.check_for_odirect_support',
with mock.patch('cinder.volume.volume_utils.check_for_odirect_support',
return_value=True):
output = image_utils.convert_image(source, dest, out_format,
throttle=throttle)
@ -149,7 +149,7 @@ class TestConvertImage(test.TestCase):
mock_exec.reset_mock()
with mock.patch('cinder.volume.utils.check_for_odirect_support',
with mock.patch('cinder.volume.volume_utils.check_for_odirect_support',
return_value=False):
output = image_utils.convert_image(source, dest, out_format)
@ -170,7 +170,7 @@ class TestConvertImage(test.TestCase):
mock_info.side_effect = ValueError
throttle = throttling.Throttle(prefix=['cgcmd'])
with mock.patch('cinder.volume.utils.check_for_odirect_support',
with mock.patch('cinder.volume.volume_utils.check_for_odirect_support',
return_value=True):
output = image_utils.convert_image(source, dest, out_format,
throttle=throttle)
@ -183,7 +183,7 @@ class TestConvertImage(test.TestCase):
mock_exec.reset_mock()
with mock.patch('cinder.volume.utils.check_for_odirect_support',
with mock.patch('cinder.volume.volume_utils.check_for_odirect_support',
return_value=False):
output = image_utils.convert_image(source, dest, out_format)
@ -192,7 +192,7 @@ class TestConvertImage(test.TestCase):
'-O', out_format, source, dest,
run_as_root=True)
@mock.patch('cinder.volume.utils.check_for_odirect_support',
@mock.patch('cinder.volume.volume_utils.check_for_odirect_support',
return_value=True)
@mock.patch('cinder.image.image_utils.qemu_img_info')
@mock.patch('cinder.utils.execute')
@ -217,7 +217,7 @@ class TestConvertImage(test.TestCase):
source, dest,
run_as_root=True)
@mock.patch('cinder.volume.utils.check_for_odirect_support',
@mock.patch('cinder.volume.volume_utils.check_for_odirect_support',
return_value=True)
@mock.patch('cinder.image.image_utils.qemu_img_info')
@mock.patch('cinder.utils.execute')
@ -253,7 +253,7 @@ class TestConvertImage(test.TestCase):
out_format = mock.sentinel.out_format
mock_info.return_value.virtual_size = 1048576
with mock.patch('cinder.volume.utils.check_for_odirect_support',
with mock.patch('cinder.volume.volume_utils.check_for_odirect_support',
return_value=True):
output = image_utils.convert_image(source, dest, out_format,
src_format='AMI')
@ -266,7 +266,7 @@ class TestConvertImage(test.TestCase):
@mock.patch('cinder.image.image_utils.qemu_img_info')
@mock.patch('cinder.utils.execute')
@mock.patch('cinder.utils.is_blk_device', return_value=False)
@mock.patch('cinder.volume.utils.check_for_odirect_support')
@mock.patch('cinder.volume.volume_utils.check_for_odirect_support')
def test_convert_to_vhd(self, mock_check_odirect, mock_isblk,
mock_exec, mock_info):
source = mock.sentinel.source
@ -307,7 +307,7 @@ class TestConvertImage(test.TestCase):
run_as_root=True)
@mock.patch('cinder.image.image_utils.CONF')
@mock.patch('cinder.volume.utils.check_for_odirect_support',
@mock.patch('cinder.volume.volume_utils.check_for_odirect_support',
return_value=True)
@mock.patch('cinder.image.image_utils.qemu_img_info')
@mock.patch('cinder.utils.execute')

2
cinder/tests/unit/test_macrosan_drivers.py

@ -26,8 +26,8 @@ from cinder.volume import configuration as conf
from cinder.volume.drivers.macrosan import devop_client
from cinder.volume.drivers.macrosan import driver
from cinder.volume import qos_specs
from cinder.volume import utils as volutils
from cinder.volume import volume_types
from cinder.volume import volume_utils as volutils
test_volume = (

2
cinder/tests/unit/test_utils.py

@ -33,7 +33,7 @@ from cinder import exception
from cinder import test
from cinder.tests.unit import fake_constants as fake
from cinder import utils
from cinder.volume import utils as volume_utils
from cinder.volume import volume_utils
POOL_CAPS = {'total_capacity_gb': 0,
'free_capacity_gb': 0,

2
cinder/tests/unit/test_volume_cleanup.py

@ -37,7 +37,7 @@ class VolumeCleanupTestCase(base.BaseVolumeTestCase):
super(VolumeCleanupTestCase, self).setUp()
self.service_id = 1
self.mock_object(service.Service, 'service_id', self.service_id)
self.patch('cinder.volume.utils.clear_volume', autospec=True)
self.patch('cinder.volume.volume_utils.clear_volume', autospec=True)
def _assert_workers_are_removed(self):
workers = db.worker_get_all(self.context, read_deleted='yes')

22
cinder/tests/unit/test_volume_transfer.py

@ -40,7 +40,7 @@ class VolumeTransferTestCase(test.TestCase):
project_id=fake.PROJECT_ID)
self.updated_at = timeutils.utcnow()
@mock.patch('cinder.volume.utils.notify_about_volume_usage')
@mock.patch('cinder.volume.volume_utils.notify_about_volume_usage')
def test_transfer_volume_create_delete(self, mock_notify):
tx_api = transfer_api.API()
volume = utils.create_volume(self.ctxt, updated_at=self.updated_at)
@ -81,7 +81,7 @@ class VolumeTransferTestCase(test.TestCase):
tx_api.create,
self.ctxt, volume.id, 'Description')
@mock.patch('cinder.volume.utils.notify_about_volume_usage')
@mock.patch('cinder.volume.volume_utils.notify_about_volume_usage')
def test_transfer_accept_invalid_authkey(self, mock_notify):
svc = self.start_service('volume', host='test_host')
self.addCleanup(svc.stop)
@ -100,7 +100,7 @@ class VolumeTransferTestCase(test.TestCase):
tx_api.accept,
self.ctxt, transfer['id'], 'wrong')
@mock.patch('cinder.volume.utils.notify_about_volume_usage')
@mock.patch('cinder.volume.volume_utils.notify_about_volume_usage')
def test_transfer_accept_invalid_volume(self, mock_notify):
svc = self.start_service('volume', host='test_host')
self.addCleanup(svc.stop)
@ -130,7 +130,7 @@ class VolumeTransferTestCase(test.TestCase):
mock_notify.assert_has_calls(calls)
self.assertEqual(3, mock_notify.call_count)
@mock.patch('cinder.volume.utils.notify_about_volume_usage')
@mock.patch('cinder.volume.volume_utils.notify_about_volume_usage')
def test_transfer_accept_volume_in_consistencygroup(self, mock_notify):
svc = self.start_service('volume', host='test_host')
self.addCleanup(svc.stop)
@ -149,7 +149,7 @@ class VolumeTransferTestCase(test.TestCase):
@mock.patch.object(QUOTAS, "limit_check")
@mock.patch.object(QUOTAS, "reserve")
@mock.patch.object(QUOTAS, "add_volume_type_opts")
@mock.patch('cinder.volume.utils.notify_about_volume_usage')
@mock.patch('cinder.volume.volume_utils.notify_about_volume_usage')
def test_transfer_accept(self, mock_notify, mock_quota_voltype,
mock_quota_reserve, mock_quota_limit):
svc = self.start_service('volume', host='test_host')
@ -203,7 +203,7 @@ class VolumeTransferTestCase(test.TestCase):
@mock.patch.object(QUOTAS, "reserve")
@mock.patch.object(QUOTAS, "add_volume_type_opts")
@mock.patch('cinder.volume.utils.notify_about_volume_usage')
@mock.patch('cinder.volume.volume_utils.notify_about_volume_usage')
def test_transfer_accept_over_quota(self, mock_notify, mock_quota_voltype,
mock_quota_reserve):
svc = self.start_service('volume', host='test_host')
@ -236,7 +236,7 @@ class VolumeTransferTestCase(test.TestCase):
self.assertEqual(2, mock_notify.call_count)
@mock.patch.object(QUOTAS, "limit_check")
@mock.patch('cinder.volume.utils.notify_about_volume_usage')
@mock.patch('cinder.volume.volume_utils.notify_about_volume_usage')
def test_transfer_accept_over_quota_check_limit(self, mock_notify,
mock_quota_limit):
svc = self.start_service('volume', host='test_host')
@ -287,7 +287,7 @@ class VolumeTransferTestCase(test.TestCase):
ts = tx_api.get_all(nctxt)
self.assertEqual(0, len(ts), 'Unexpected transfers listed.')
@mock.patch('cinder.volume.utils.notify_about_volume_usage')
@mock.patch('cinder.volume.volume_utils.notify_about_volume_usage')
def test_delete_transfer_with_deleted_volume(self, mock_notify):
# create a volume
volume = utils.create_volume(self.ctxt, updated_at=self.updated_at)
@ -309,7 +309,7 @@ class VolumeTransferTestCase(test.TestCase):
self.ctxt,
transfer['id'])
@mock.patch('cinder.volume.utils.notify_about_volume_usage')
@mock.patch('cinder.volume.volume_utils.notify_about_volume_usage')
def test_transfer_accept_with_snapshots(self, mock_notify):
svc = self.start_service('volume', host='test_host')
self.addCleanup(svc.stop)
@ -350,7 +350,7 @@ class VolumeTransferTestCase(test.TestCase):
self.assertEqual(1, usages.get('volumes', {}).get('in_use', 0))
self.assertEqual(1, usages.get('snapshots', {}).get('in_use', 0))
@mock.patch('cinder.volume.utils.notify_about_volume_usage')
@mock.patch('cinder.volume.volume_utils.notify_about_volume_usage')
def test_transfer_accept_with_snapshots_invalid(self, mock_notify):
svc = self.start_service('volume', host='test_host')
self.addCleanup(svc.stop)
@ -364,7 +364,7 @@ class VolumeTransferTestCase(test.TestCase):
self.assertRaises(exception.InvalidSnapshot,
tx_api.create, self.ctxt, volume.id, 'Description')
@mock.patch('cinder.volume.utils.notify_about_volume_usage')
@mock.patch('cinder.volume.volume_utils.notify_about_volume_usage')
def test_transfer_accept_with_detail_records(self, mock_notify):
svc = self.start_service('volume', host='test_host')
self.addCleanup(svc.stop)

106
cinder/tests/unit/test_volume_utils.py

<
@ -42,17 +42,17 @@ from cinder.tests.unit.image import fake as fake_image
from cinder.tests.unit import utils as test_utils
from cinder import utils
from cinder.volume import throttling
from cinder.volume import utils as volume_utils
from cinder.volume import volume_types
from cinder.volume import volume_utils
CONF = cfg.CONF
class NotifyUsageTestCase(test.TestCase):
@mock.patch('cinder.volume.utils._usage_from_volume')
@mock.patch('cinder.volume.utils.CONF')
@mock.patch('cinder.volume.utils.rpc')
@mock.patch('cinder.volume.volume_utils._usage_from_volume')
@mock.patch('cinder.volume.volume_utils.CONF')
@mock.patch('cinder.volume.volume_utils.rpc')
def test_notify_about_volume_usage(self, mock_rpc, mock_conf, mock_usage):
mock_conf.host = 'host1'
output = volume_utils.notify_about_volume_usage(mock.sentinel.context,
@ -67,9 +67,9 @@ class NotifyUsageTestCase(test.TestCase):
'volume.test_suffix',
mock_usage.return_value)
@mock.patch('cinder.volume.utils._usage_from_volume')
@mock.patch('cinder.volume.utils.CONF')
@mock.patch('cinder.volume.utils.rpc')
@mock.patch('cinder.volume.volume_utils._usage_from_volume')
@mock.patch('cinder.volume.volume_utils.CONF')
@mock.patch('cinder.volume.volume_utils.rpc')
def test_notify_about_volume_usage_with_kwargs(self, mock_rpc, mock_conf,
mock_usage):
mock_conf.host = 'host1'
@ -88,9 +88,9 @@ class NotifyUsageTestCase(test.TestCase):
'volume.test_suffix',
mock_usage.return_value)
@mock.patch('cinder.volume.utils._usage_from_snapshot')
@mock.patch('cinder.volume.utils.CONF')
@mock.patch('cinder.volume.utils.rpc')
@mock.patch('cinder.volume.volume_utils._usage_from_snapshot')
@mock.patch('cinder.volume.volume_utils.CONF')
@mock.patch('cinder.volume.volume_utils.rpc')
def test_notify_about_snapshot_usage(self, mock_rpc,
mock_conf, mock_usage):
mock_conf.host = 'host1'
@ -107,9 +107,9 @@ class NotifyUsageTestCase(test.TestCase):
'snapshot.test_suffix',
mock_usage.return_value)
@mock.patch('cinder.volume.utils._usage_from_snapshot')
@mock.patch('cinder.volume.utils.CONF')
@mock.patch('cinder.volume.utils.rpc')
@mock.patch('cinder.volume.volume_utils._usage_from_snapshot')
@mock.patch('cinder.volume.volume_utils.CONF')
@mock.patch('cinder.volume.volume_utils.rpc')
def test_notify_about_snapshot_usage_with_kwargs(self, mock_rpc, mock_conf,
mock_usage):
mock_conf.host = 'host1'
@ -265,9 +265,9 @@ class NotifyUsageTestCase(test.TestCase):
}
self.assertEqual(expected_volume, usage_info)
@mock.patch('cinder.volume.utils._usage_from_consistencygroup')
@mock.patch('cinder.volume.utils.CONF')
@mock.patch('cinder.volume.utils.rpc')
@mock.patch('cinder.volume.volume_utils._usage_from_consistencygroup')
@mock.patch('cinder.volume.volume_utils.CONF')
@mock.patch('cinder.volume.volume_utils.rpc')
def test_notify_about_consistencygroup_usage(self, mock_rpc,
mock_conf, mock_usage):
mock_conf.host = 'host1'
@ -284,9 +284,9 @@ class NotifyUsageTestCase(test.TestCase):
'consistencygroup.test_suffix',
mock_usage.return_value)
@mock.patch('cinder.volume.utils._usage_from_consistencygroup')
@mock.patch('cinder.volume.utils.CONF')
@mock.patch('cinder.volume.utils.rpc')
@mock.patch('cinder.volume.volume_utils._usage_from_consistencygroup')
@mock.patch('cinder.volume.volume_utils.CONF')
@mock.patch('cinder.volume.volume_utils.rpc')
def test_notify_about_consistencygroup_usage_with_kwargs(self, mock_rpc,
mock_conf,
mock_usage):
@ -307,9 +307,9 @@ class NotifyUsageTestCase(test.TestCase):
'consistencygroup.test_suffix',
mock_usage.return_value)
@mock.patch('cinder.volume.utils._usage_from_cgsnapshot')
@mock.patch('cinder.volume.utils.CONF')
@mock.patch('cinder.volume.utils.rpc')
@mock.patch('cinder.volume.volume_utils._usage_from_cgsnapshot')
@mock.patch('cinder.volume.volume_utils.CONF')
@mock.patch('cinder.volume.volume_utils.rpc')
def test_notify_about_cgsnapshot_usage(self, mock_rpc,
mock_conf, mock_usage):
mock_conf.host = 'host1'
@ -325,9 +325,9 @@ class NotifyUsageTestCase(test.TestCase):
'cgsnapshot.test_suffix',
mock_usage.return_value)
@mock.patch('cinder.volume.utils._usage_from_cgsnapshot')
@mock.patch('cinder.volume.utils.CONF')
@mock.patch('cinder.volume.utils.rpc')
@mock.patch('cinder.volume.volume_utils._usage_from_cgsnapshot')
@mock.patch('cinder.volume.volume_utils.CONF')
@mock.patch('cinder.volume.volume_utils.rpc')
def test_notify_about_cgsnapshot_usage_with_kwargs(self, mock_rpc,
mock_conf, mock_usage):
mock_conf.host = 'host1'
@ -404,9 +404,9 @@ class LVMVolumeDriverTestCase(test.TestCase):
bs = volume_utils._check_blocksize('ABM')
self.assertEqual('1M', bs)
@mock.patch('cinder.volume.utils._usage_from_capacity')
@mock.patch('cinder.volume.utils.CONF')
@mock.patch('cinder.volume.utils.rpc')
@mock.patch('cinder.volume.volume_utils._usage_from_capacity')