Merge "Move brick calls from cinder.utils to volume_utils"
This commit is contained in:
commit
4bea91f1da
@ -455,7 +455,7 @@ class BackupManager(manager.SchedulerDependentManager):
|
|||||||
|
|
||||||
backup_service = self.service(context)
|
backup_service = self.service(context)
|
||||||
|
|
||||||
properties = utils.brick_get_connector_properties()
|
properties = volume_utils.brick_get_connector_properties()
|
||||||
|
|
||||||
# NOTE(geguileo): Not all I/O disk operations properly do greenthread
|
# NOTE(geguileo): Not all I/O disk operations properly do greenthread
|
||||||
# context switching and may end up blocking the greenthread, so we go
|
# context switching and may end up blocking the greenthread, so we go
|
||||||
@ -631,7 +631,7 @@ class BackupManager(manager.SchedulerDependentManager):
|
|||||||
orig_key_id = volume.encryption_key_id
|
orig_key_id = volume.encryption_key_id
|
||||||
backup_service = self.service(context)
|
backup_service = self.service(context)
|
||||||
|
|
||||||
properties = utils.brick_get_connector_properties()
|
properties = volume_utils.brick_get_connector_properties()
|
||||||
secure_enabled = (
|
secure_enabled = (
|
||||||
self.volume_rpcapi.secure_file_operations_enabled(context,
|
self.volume_rpcapi.secure_file_operations_enabled(context,
|
||||||
volume))
|
volume))
|
||||||
@ -1046,7 +1046,7 @@ class BackupManager(manager.SchedulerDependentManager):
|
|||||||
use_multipath = CONF.use_multipath_for_image_xfer
|
use_multipath = CONF.use_multipath_for_image_xfer
|
||||||
device_scan_attempts = CONF.num_volume_device_scan_tries
|
device_scan_attempts = CONF.num_volume_device_scan_tries
|
||||||
protocol = conn['driver_volume_type']
|
protocol = conn['driver_volume_type']
|
||||||
connector = utils.brick_get_connector(
|
connector = volume_utils.brick_get_connector(
|
||||||
protocol,
|
protocol,
|
||||||
use_multipath=use_multipath,
|
use_multipath=use_multipath,
|
||||||
device_scan_attempts=device_scan_attempts,
|
device_scan_attempts=device_scan_attempts,
|
||||||
|
@ -685,7 +685,7 @@ class BackupTestCase(BaseBackupTest):
|
|||||||
self.assertEqual(fields.BackupStatus.ERROR, backup.status)
|
self.assertEqual(fields.BackupStatus.ERROR, backup.status)
|
||||||
self.assertTrue(mock_run_backup.called)
|
self.assertTrue(mock_run_backup.called)
|
||||||
|
|
||||||
@mock.patch('cinder.utils.brick_get_connector_properties')
|
@mock.patch('cinder.volume.volume_utils.brick_get_connector_properties')
|
||||||
@mock.patch('cinder.volume.rpcapi.VolumeAPI.get_backup_device')
|
@mock.patch('cinder.volume.rpcapi.VolumeAPI.get_backup_device')
|
||||||
@mock.patch('cinder.utils.temporary_chown')
|
@mock.patch('cinder.utils.temporary_chown')
|
||||||
@mock.patch('builtins.open', wraps=open)
|
@mock.patch('builtins.open', wraps=open)
|
||||||
@ -735,7 +735,7 @@ class BackupTestCase(BaseBackupTest):
|
|||||||
self.assertEqual(vol_size, backup['size'])
|
self.assertEqual(vol_size, backup['size'])
|
||||||
self.assertIsNone(backup.encryption_key_id)
|
self.assertIsNone(backup.encryption_key_id)
|
||||||
|
|
||||||
@mock.patch('cinder.utils.brick_get_connector_properties')
|
@mock.patch('cinder.volume.volume_utils.brick_get_connector_properties')
|
||||||
@mock.patch('cinder.volume.rpcapi.VolumeAPI.get_backup_device')
|
@mock.patch('cinder.volume.rpcapi.VolumeAPI.get_backup_device')
|
||||||
@mock.patch('cinder.utils.temporary_chown')
|
@mock.patch('cinder.utils.temporary_chown')
|
||||||
@mock.patch('builtins.open')
|
@mock.patch('builtins.open')
|
||||||
@ -771,7 +771,7 @@ class BackupTestCase(BaseBackupTest):
|
|||||||
self.assertEqual(vol_size, backup.size)
|
self.assertEqual(vol_size, backup.size)
|
||||||
self.assertIsNone(backup.parent_id)
|
self.assertIsNone(backup.parent_id)
|
||||||
|
|
||||||
@mock.patch('cinder.utils.brick_get_connector_properties')
|
@mock.patch('cinder.volume.volume_utils.brick_get_connector_properties')
|
||||||
@mock.patch('cinder.volume.rpcapi.VolumeAPI.get_backup_device')
|
@mock.patch('cinder.volume.rpcapi.VolumeAPI.get_backup_device')
|
||||||
@mock.patch('cinder.utils.temporary_chown')
|
@mock.patch('cinder.utils.temporary_chown')
|
||||||
@mock.patch('builtins.open')
|
@mock.patch('builtins.open')
|
||||||
@ -806,7 +806,7 @@ class BackupTestCase(BaseBackupTest):
|
|||||||
self.assertEqual(vol_size, backup.size)
|
self.assertEqual(vol_size, backup.size)
|
||||||
self.assertEqual(parent_backup.id, backup.parent_id)
|
self.assertEqual(parent_backup.id, backup.parent_id)
|
||||||
|
|
||||||
@mock.patch('cinder.utils.brick_get_connector_properties')
|
@mock.patch('cinder.volume.volume_utils.brick_get_connector_properties')
|
||||||
@mock.patch('cinder.volume.rpcapi.VolumeAPI.get_backup_device')
|
@mock.patch('cinder.volume.rpcapi.VolumeAPI.get_backup_device')
|
||||||
@mock.patch('cinder.utils.temporary_chown')
|
@mock.patch('cinder.utils.temporary_chown')
|
||||||
@mock.patch('builtins.open')
|
@mock.patch('builtins.open')
|
||||||
@ -843,7 +843,7 @@ class BackupTestCase(BaseBackupTest):
|
|||||||
backup = db.backup_get(self.ctxt, backup.id)
|
backup = db.backup_get(self.ctxt, backup.id)
|
||||||
self.assertEqual(fields.BackupStatus.ERROR, backup.status)
|
self.assertEqual(fields.BackupStatus.ERROR, backup.status)
|
||||||
|
|
||||||
@mock.patch('cinder.utils.brick_get_connector_properties')
|
@mock.patch('cinder.volume.volume_utils.brick_get_connector_properties')
|
||||||
@mock.patch('cinder.volume.rpcapi.VolumeAPI.get_backup_device')
|
@mock.patch('cinder.volume.rpcapi.VolumeAPI.get_backup_device')
|
||||||
@mock.patch('cinder.utils.temporary_chown')
|
@mock.patch('cinder.utils.temporary_chown')
|
||||||
@mock.patch('builtins.open')
|
@mock.patch('builtins.open')
|
||||||
@ -901,7 +901,7 @@ class BackupTestCase(BaseBackupTest):
|
|||||||
self.assertRaises(exception.InvalidSnapshot,
|
self.assertRaises(exception.InvalidSnapshot,
|
||||||
self.backup_mgr.create_backup, self.ctxt, backup)
|
self.backup_mgr.create_backup, self.ctxt, backup)
|
||||||
|
|
||||||
@mock.patch('cinder.utils.brick_get_connector_properties')
|
@mock.patch('cinder.volume.volume_utils.brick_get_connector_properties')
|
||||||
@mock.patch('cinder.volume.rpcapi.VolumeAPI.get_backup_device')
|
@mock.patch('cinder.volume.rpcapi.VolumeAPI.get_backup_device')
|
||||||
@mock.patch('cinder.utils.temporary_chown')
|
@mock.patch('cinder.utils.temporary_chown')
|
||||||
@mock.patch('builtins.open')
|
@mock.patch('builtins.open')
|
||||||
@ -1026,7 +1026,7 @@ class BackupTestCase(BaseBackupTest):
|
|||||||
|
|
||||||
@mock.patch('cinder.volume.rpcapi.VolumeAPI.get_backup_device')
|
@mock.patch('cinder.volume.rpcapi.VolumeAPI.get_backup_device')
|
||||||
@mock.patch('cinder.volume.volume_utils.clone_encryption_key')
|
@mock.patch('cinder.volume.volume_utils.clone_encryption_key')
|
||||||
@mock.patch('cinder.utils.brick_get_connector_properties')
|
@mock.patch('cinder.volume.volume_utils.brick_get_connector_properties')
|
||||||
def test_create_backup_encrypted_volume(self,
|
def test_create_backup_encrypted_volume(self,
|
||||||
mock_connector_properties,
|
mock_connector_properties,
|
||||||
mock_clone_encryption_key,
|
mock_clone_encryption_key,
|
||||||
@ -1054,7 +1054,7 @@ class BackupTestCase(BaseBackupTest):
|
|||||||
|
|
||||||
@mock.patch('cinder.volume.rpcapi.VolumeAPI.get_backup_device')
|
@mock.patch('cinder.volume.rpcapi.VolumeAPI.get_backup_device')
|
||||||
@mock.patch('cinder.volume.volume_utils.clone_encryption_key')
|
@mock.patch('cinder.volume.volume_utils.clone_encryption_key')
|
||||||
@mock.patch('cinder.utils.brick_get_connector_properties')
|
@mock.patch('cinder.volume.volume_utils.brick_get_connector_properties')
|
||||||
def test_create_backup_encrypted_volume_again(self,
|
def test_create_backup_encrypted_volume_again(self,
|
||||||
mock_connector_properties,
|
mock_connector_properties,
|
||||||
mock_clone_encryption_key,
|
mock_clone_encryption_key,
|
||||||
@ -1217,7 +1217,7 @@ class BackupTestCase(BaseBackupTest):
|
|||||||
backup = db.backup_get(self.ctxt, backup.id)
|
backup = db.backup_get(self.ctxt, backup.id)
|
||||||
self.assertEqual(fields.BackupStatus.AVAILABLE, backup['status'])
|
self.assertEqual(fields.BackupStatus.AVAILABLE, backup['status'])
|
||||||
|
|
||||||
@mock.patch('cinder.utils.brick_get_connector_properties')
|
@mock.patch('cinder.volume.volume_utils.brick_get_connector_properties')
|
||||||
@mock.patch('cinder.utils.temporary_chown')
|
@mock.patch('cinder.utils.temporary_chown')
|
||||||
@mock.patch('builtins.open', wraps=open)
|
@mock.patch('builtins.open', wraps=open)
|
||||||
@mock.patch.object(os.path, 'isdir', return_value=False)
|
@mock.patch.object(os.path, 'isdir', return_value=False)
|
||||||
@ -1267,7 +1267,7 @@ class BackupTestCase(BaseBackupTest):
|
|||||||
self.assertNotEqual(backup.id, vol.metadata.get('src_backup_id'))
|
self.assertNotEqual(backup.id, vol.metadata.get('src_backup_id'))
|
||||||
self.assertEqual(fields.BackupStatus.AVAILABLE, backup['status'])
|
self.assertEqual(fields.BackupStatus.AVAILABLE, backup['status'])
|
||||||
|
|
||||||
@mock.patch('cinder.utils.brick_get_connector_properties')
|
@mock.patch('cinder.volume.volume_utils.brick_get_connector_properties')
|
||||||
@mock.patch('cinder.utils.temporary_chown')
|
@mock.patch('cinder.utils.temporary_chown')
|
||||||
@mock.patch('builtins.open', wraps=open)
|
@mock.patch('builtins.open', wraps=open)
|
||||||
@mock.patch.object(os.path, 'isdir', return_value=False)
|
@mock.patch.object(os.path, 'isdir', return_value=False)
|
||||||
@ -1355,7 +1355,7 @@ class BackupTestCase(BaseBackupTest):
|
|||||||
@mock.patch('cinder.volume.volume_utils.delete_encryption_key')
|
@mock.patch('cinder.volume.volume_utils.delete_encryption_key')
|
||||||
@mock.patch(
|
@mock.patch(
|
||||||
'cinder.tests.unit.backup.fake_service.FakeBackupService.restore')
|
'cinder.tests.unit.backup.fake_service.FakeBackupService.restore')
|
||||||
@mock.patch('cinder.utils.brick_get_connector_properties')
|
@mock.patch('cinder.volume.volume_utils.brick_get_connector_properties')
|
||||||
def test_restore_backup_encrypted_volume(self,
|
def test_restore_backup_encrypted_volume(self,
|
||||||
mock_connector_properties,
|
mock_connector_properties,
|
||||||
mock_backup_driver_restore,
|
mock_backup_driver_restore,
|
||||||
@ -1388,7 +1388,7 @@ class BackupTestCase(BaseBackupTest):
|
|||||||
@mock.patch('cinder.volume.volume_utils.delete_encryption_key')
|
@mock.patch('cinder.volume.volume_utils.delete_encryption_key')
|
||||||
@mock.patch(
|
@mock.patch(
|
||||||
'cinder.tests.unit.backup.fake_service.FakeBackupService.restore')
|
'cinder.tests.unit.backup.fake_service.FakeBackupService.restore')
|
||||||
@mock.patch('cinder.utils.brick_get_connector_properties')
|
@mock.patch('cinder.volume.volume_utils.brick_get_connector_properties')
|
||||||
def test_restore_backup_new_encrypted_volume(self,
|
def test_restore_backup_new_encrypted_volume(self,
|
||||||
mock_connector_properties,
|
mock_connector_properties,
|
||||||
mock_backup_driver_restore,
|
mock_backup_driver_restore,
|
||||||
@ -1449,7 +1449,7 @@ class BackupTestCase(BaseBackupTest):
|
|||||||
@mock.patch('cinder.volume.volume_utils.delete_encryption_key')
|
@mock.patch('cinder.volume.volume_utils.delete_encryption_key')
|
||||||
@mock.patch(
|
@mock.patch(
|
||||||
'cinder.tests.unit.backup.fake_service.FakeBackupService.restore')
|
'cinder.tests.unit.backup.fake_service.FakeBackupService.restore')
|
||||||
@mock.patch('cinder.utils.brick_get_connector_properties')
|
@mock.patch('cinder.volume.volume_utils.brick_get_connector_properties')
|
||||||
def test_restore_backup_glean_key_id(self,
|
def test_restore_backup_glean_key_id(self,
|
||||||
mock_connector_properties,
|
mock_connector_properties,
|
||||||
mock_backup_driver_restore,
|
mock_backup_driver_restore,
|
||||||
|
@ -723,13 +723,13 @@ class AuditPeriodTest(test.TestCase):
|
|||||||
class BrickUtils(test.TestCase):
|
class BrickUtils(test.TestCase):
|
||||||
"""Unit test to test the brick utility wrapper functions."""
|
"""Unit test to test the brick utility wrapper functions."""
|
||||||
|
|
||||||
@mock.patch('cinder.utils.CONF')
|
@mock.patch('cinder.volume.volume_utils.CONF')
|
||||||
@mock.patch('os_brick.initiator.connector.get_connector_properties')
|
@mock.patch('os_brick.initiator.connector.get_connector_properties')
|
||||||
@mock.patch('cinder.utils.get_root_helper')
|
@mock.patch('cinder.utils.get_root_helper')
|
||||||
def test_brick_get_connector_properties(self, mock_helper, mock_get,
|
def test_brick_get_connector_properties(self, mock_helper, mock_get,
|
||||||
mock_conf):
|
mock_conf):
|
||||||
mock_conf.my_ip = '1.2.3.4'
|
mock_conf.my_ip = '1.2.3.4'
|
||||||
output = utils.brick_get_connector_properties()
|
output = volume_utils.brick_get_connector_properties()
|
||||||
mock_helper.assert_called_once_with()
|
mock_helper.assert_called_once_with()
|
||||||
mock_get.assert_called_once_with(mock_helper.return_value, '1.2.3.4',
|
mock_get.assert_called_once_with(mock_helper.return_value, '1.2.3.4',
|
||||||
False, False)
|
False, False)
|
||||||
@ -738,7 +738,7 @@ class BrickUtils(test.TestCase):
|
|||||||
@mock.patch('os_brick.initiator.connector.InitiatorConnector.factory')
|
@mock.patch('os_brick.initiator.connector.InitiatorConnector.factory')
|
||||||
@mock.patch('cinder.utils.get_root_helper')
|
@mock.patch('cinder.utils.get_root_helper')
|
||||||
def test_brick_get_connector(self, mock_helper, mock_factory):
|
def test_brick_get_connector(self, mock_helper, mock_factory):
|
||||||
output = utils.brick_get_connector('protocol')
|
output = volume_utils.brick_get_connector('protocol')
|
||||||
mock_helper.assert_called_once_with()
|
mock_helper.assert_called_once_with()
|
||||||
self.assertEqual(mock_factory.return_value, output)
|
self.assertEqual(mock_factory.return_value, output)
|
||||||
mock_factory.assert_called_once_with(
|
mock_factory.assert_called_once_with(
|
||||||
@ -756,7 +756,9 @@ class BrickUtils(test.TestCase):
|
|||||||
ctxt = mock.Mock(name='context')
|
ctxt = mock.Mock(name='context')
|
||||||
mock_encryptor = mock.Mock()
|
mock_encryptor = mock.Mock()
|
||||||
mock_get_encryptor.return_value = mock_encryptor
|
mock_get_encryptor.return_value = mock_encryptor
|
||||||
utils.brick_attach_volume_encryptor(ctxt, attach_info, encryption)
|
volume_utils.brick_attach_volume_encryptor(ctxt,
|
||||||
|
attach_info,
|
||||||
|
encryption)
|
||||||
|
|
||||||
connection_info = attach_info['conn']
|
connection_info = attach_info['conn']
|
||||||
connection_info['data']['device_path'] = attach_info['device']['path']
|
connection_info['data']['device_path'] = attach_info['device']['path']
|
||||||
@ -779,7 +781,7 @@ class BrickUtils(test.TestCase):
|
|||||||
encryption = {'encryption_key_id': fake.ENCRYPTION_KEY_ID}
|
encryption = {'encryption_key_id': fake.ENCRYPTION_KEY_ID}
|
||||||
mock_encryptor = mock.Mock()
|
mock_encryptor = mock.Mock()
|
||||||
mock_get_encryptor.return_value = mock_encryptor
|
mock_get_encryptor.return_value = mock_encryptor
|
||||||
utils.brick_detach_volume_encryptor(attach_info, encryption)
|
volume_utils.brick_detach_volume_encryptor(attach_info, encryption)
|
||||||
|
|
||||||
mock_helper.assert_called_once_with()
|
mock_helper.assert_called_once_with()
|
||||||
connection_info = attach_info['conn']
|
connection_info = attach_info['conn']
|
||||||
|
@ -470,7 +470,7 @@ def patch_for_unity_adapter(func):
|
|||||||
@mock.patch('cinder.volume.drivers.dell_emc.unity.utils.'
|
@mock.patch('cinder.volume.drivers.dell_emc.unity.utils.'
|
||||||
'group_is_cg',
|
'group_is_cg',
|
||||||
new=group_is_cg)
|
new=group_is_cg)
|
||||||
@mock.patch('cinder.utils.brick_get_connector_properties',
|
@mock.patch('cinder.volume.volume_utils.brick_get_connector_properties',
|
||||||
new=get_connector_properties)
|
new=get_connector_properties)
|
||||||
def func_wrapper(*args, **kwargs):
|
def func_wrapper(*args, **kwargs):
|
||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
|
@ -1107,7 +1107,7 @@ class FlashSystemDriverTestCase(test.TestCase):
|
|||||||
@mock.patch.object(volume_utils, 'copy_volume')
|
@mock.patch.object(volume_utils, 'copy_volume')
|
||||||
@mock.patch.object(flashsystem_fc.FlashSystemFCDriver, '_scan_device')
|
@mock.patch.object(flashsystem_fc.FlashSystemFCDriver, '_scan_device')
|
||||||
@mock.patch.object(flashsystem_fc.FlashSystemFCDriver, '_remove_device')
|
@mock.patch.object(flashsystem_fc.FlashSystemFCDriver, '_remove_device')
|
||||||
@mock.patch.object(utils, 'brick_get_connector_properties')
|
@mock.patch.object(volume_utils, 'brick_get_connector_properties')
|
||||||
def test_flashsystem_copy_vdisk_data(self,
|
def test_flashsystem_copy_vdisk_data(self,
|
||||||
_connector,
|
_connector,
|
||||||
_remove_device,
|
_remove_device,
|
||||||
|
@ -352,8 +352,8 @@ class InfiniboxDriverTestCase(InfiniboxDriverTestCaseBase):
|
|||||||
self.driver.create_snapshot, test_snapshot)
|
self.driver.create_snapshot, test_snapshot)
|
||||||
|
|
||||||
@mock.patch("cinder.volume.volume_utils.copy_volume")
|
@mock.patch("cinder.volume.volume_utils.copy_volume")
|
||||||
@mock.patch("cinder.utils.brick_get_connector")
|
@mock.patch("cinder.volume.volume_utils.brick_get_connector")
|
||||||
@mock.patch("cinder.utils.brick_get_connector_properties",
|
@mock.patch("cinder.volume.volume_utils.brick_get_connector_properties",
|
||||||
return_value=test_connector)
|
return_value=test_connector)
|
||||||
@mock.patch("cinder.volume.volume_types.get_volume_type_qos_specs")
|
@mock.patch("cinder.volume.volume_types.get_volume_type_qos_specs")
|
||||||
def test_create_volume_from_snapshot(self, *mocks):
|
def test_create_volume_from_snapshot(self, *mocks):
|
||||||
@ -371,7 +371,7 @@ class InfiniboxDriverTestCase(InfiniboxDriverTestCaseBase):
|
|||||||
self.driver.create_volume_from_snapshot,
|
self.driver.create_volume_from_snapshot,
|
||||||
test_clone, test_snapshot)
|
test_clone, test_snapshot)
|
||||||
|
|
||||||
@mock.patch("cinder.utils.brick_get_connector_properties",
|
@mock.patch("cinder.volume.volume_utils.brick_get_connector_properties",
|
||||||
return_value=test_connector)
|
return_value=test_connector)
|
||||||
@mock.patch("cinder.volume.volume_types.get_volume_type_qos_specs")
|
@mock.patch("cinder.volume.volume_types.get_volume_type_qos_specs")
|
||||||
def test_create_volume_from_snapshot_map_fails(self, *mocks):
|
def test_create_volume_from_snapshot_map_fails(self, *mocks):
|
||||||
@ -381,8 +381,8 @@ class InfiniboxDriverTestCase(InfiniboxDriverTestCaseBase):
|
|||||||
test_clone, test_snapshot)
|
test_clone, test_snapshot)
|
||||||
|
|
||||||
@mock.patch("cinder.volume.volume_utils.copy_volume")
|
@mock.patch("cinder.volume.volume_utils.copy_volume")
|
||||||
@mock.patch("cinder.utils.brick_get_connector")
|
@mock.patch("cinder.volume.volume_utils.brick_get_connector")
|
||||||
@mock.patch("cinder.utils.brick_get_connector_properties",
|
@mock.patch("cinder.volume.volume_utils.brick_get_connector_properties",
|
||||||
return_value=test_connector)
|
return_value=test_connector)
|
||||||
def test_create_volume_from_snapshot_delete_clone_fails(self, *mocks):
|
def test_create_volume_from_snapshot_delete_clone_fails(self, *mocks):
|
||||||
self._mock_volume.delete.side_effect = self._raise_infinisdk
|
self._mock_volume.delete.side_effect = self._raise_infinisdk
|
||||||
@ -404,8 +404,8 @@ class InfiniboxDriverTestCase(InfiniboxDriverTestCaseBase):
|
|||||||
self.driver.delete_snapshot, test_snapshot)
|
self.driver.delete_snapshot, test_snapshot)
|
||||||
|
|
||||||
@mock.patch("cinder.volume.volume_utils.copy_volume")
|
@mock.patch("cinder.volume.volume_utils.copy_volume")
|
||||||
@mock.patch("cinder.utils.brick_get_connector")
|
@mock.patch("cinder.volume.volume_utils.brick_get_connector")
|
||||||
@mock.patch("cinder.utils.brick_get_connector_properties",
|
@mock.patch("cinder.volume.volume_utils.brick_get_connector_properties",
|
||||||
return_value=test_connector)
|
return_value=test_connector)
|
||||||
@mock.patch("cinder.volume.volume_types.get_volume_type_qos_specs")
|
@mock.patch("cinder.volume.volume_types.get_volume_type_qos_specs")
|
||||||
def test_create_cloned_volume(self, *mocks):
|
def test_create_cloned_volume(self, *mocks):
|
||||||
@ -425,7 +425,7 @@ class InfiniboxDriverTestCase(InfiniboxDriverTestCaseBase):
|
|||||||
self.driver.create_cloned_volume,
|
self.driver.create_cloned_volume,
|
||||||
test_clone, test_volume)
|
test_clone, test_volume)
|
||||||
|
|
||||||
@mock.patch("cinder.utils.brick_get_connector_properties",
|
@mock.patch("cinder.volume.volume_utils.brick_get_connector_properties",
|
||||||
return_value=test_connector)
|
return_value=test_connector)
|
||||||
@mock.patch("cinder.volume.volume_types.get_volume_type_qos_specs")
|
@mock.patch("cinder.volume.volume_types.get_volume_type_qos_specs")
|
||||||
def test_create_cloned_volume_map_fails(self, *mocks):
|
def test_create_cloned_volume_map_fails(self, *mocks):
|
||||||
@ -494,8 +494,8 @@ class InfiniboxDriverTestCase(InfiniboxDriverTestCaseBase):
|
|||||||
[test_volume], [test_volume])
|
[test_volume], [test_volume])
|
||||||
|
|
||||||
@mock.patch("cinder.volume.volume_utils.copy_volume")
|
@mock.patch("cinder.volume.volume_utils.copy_volume")
|
||||||
@mock.patch("cinder.utils.brick_get_connector")
|
@mock.patch("cinder.volume.volume_utils.brick_get_connector")
|
||||||
@mock.patch("cinder.utils.brick_get_connector_properties",
|
@mock.patch("cinder.volume.volume_utils.brick_get_connector_properties",
|
||||||
return_value=test_connector)
|
return_value=test_connector)
|
||||||
@mock.patch('cinder.volume.volume_utils.is_group_a_cg_snapshot_type',
|
@mock.patch('cinder.volume.volume_utils.is_group_a_cg_snapshot_type',
|
||||||
return_value=True)
|
return_value=True)
|
||||||
@ -506,8 +506,8 @@ class InfiniboxDriverTestCase(InfiniboxDriverTestCaseBase):
|
|||||||
None, None)
|
None, None)
|
||||||
|
|
||||||
@mock.patch("cinder.volume.volume_utils.copy_volume")
|
@mock.patch("cinder.volume.volume_utils.copy_volume")
|
||||||
@mock.patch("cinder.utils.brick_get_connector")
|
@mock.patch("cinder.volume.volume_utils.brick_get_connector")
|
||||||
@mock.patch("cinder.utils.brick_get_connector_properties",
|
@mock.patch("cinder.volume.volume_utils.brick_get_connector_properties",
|
||||||
return_value=test_connector)
|
return_value=test_connector)
|
||||||
@mock.patch('cinder.volume.volume_utils.is_group_a_cg_snapshot_type',
|
@mock.patch('cinder.volume.volume_utils.is_group_a_cg_snapshot_type',
|
||||||
return_value=True)
|
return_value=True)
|
||||||
|
@ -28,7 +28,6 @@ from cinder.objects import fields
|
|||||||
from cinder.tests.unit import fake_snapshot
|
from cinder.tests.unit import fake_snapshot
|
||||||
from cinder.tests.unit import fake_volume
|
from cinder.tests.unit import fake_volume
|
||||||
from cinder.tests.unit import test
|
from cinder.tests.unit import test
|
||||||
from cinder import utils
|
|
||||||
from cinder.volume import configuration
|
from cinder.volume import configuration
|
||||||
from cinder.volume.drivers.kaminario import kaminario_common
|
from cinder.volume.drivers.kaminario import kaminario_common
|
||||||
from cinder.volume.drivers.kaminario import kaminario_fc
|
from cinder.volume.drivers.kaminario import kaminario_fc
|
||||||
@ -207,7 +206,7 @@ class TestKaminarioCommon(test.TestCase):
|
|||||||
self.assertRaises(kaminario_common.KaminarioCinderDriverException,
|
self.assertRaises(kaminario_common.KaminarioCinderDriverException,
|
||||||
self.driver.delete_snapshot, self.snap)
|
self.driver.delete_snapshot, self.snap)
|
||||||
|
|
||||||
@mock.patch.object(utils, 'brick_get_connector_properties')
|
@mock.patch.object(volume_utils, 'brick_get_connector_properties')
|
||||||
@mock.patch.object(volume_utils, 'copy_volume')
|
@mock.patch.object(volume_utils, 'copy_volume')
|
||||||
def test_create_volume_from_snapshot(self, mock_copy_volume,
|
def test_create_volume_from_snapshot(self, mock_copy_volume,
|
||||||
mock_brick_get):
|
mock_brick_get):
|
||||||
@ -218,7 +217,7 @@ class TestKaminarioCommon(test.TestCase):
|
|||||||
result = self.driver.create_volume_from_snapshot(self.vol, self.snap)
|
result = self.driver.create_volume_from_snapshot(self.vol, self.snap)
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
|
|
||||||
@mock.patch.object(utils, 'brick_get_connector_properties')
|
@mock.patch.object(volume_utils, 'brick_get_connector_properties')
|
||||||
@mock.patch.object(volume_utils, 'copy_volume')
|
@mock.patch.object(volume_utils, 'copy_volume')
|
||||||
def test_create_volume_from_snapshot_with_exception(self, mock_copy_volume,
|
def test_create_volume_from_snapshot_with_exception(self, mock_copy_volume,
|
||||||
mock_brick_get):
|
mock_brick_get):
|
||||||
@ -230,7 +229,7 @@ class TestKaminarioCommon(test.TestCase):
|
|||||||
self.driver.create_volume_from_snapshot, self.vol,
|
self.driver.create_volume_from_snapshot, self.vol,
|
||||||
self.snap)
|
self.snap)
|
||||||
|
|
||||||
@mock.patch.object(utils, 'brick_get_connector_properties')
|
@mock.patch.object(volume_utils, 'brick_get_connector_properties')
|
||||||
@mock.patch.object(volume_utils, 'copy_volume')
|
@mock.patch.object(volume_utils, 'copy_volume')
|
||||||
def test_create_cloned_volume(self, mock_copy_volume, mock_brick_get):
|
def test_create_cloned_volume(self, mock_copy_volume, mock_brick_get):
|
||||||
"""Test create_cloned_volume."""
|
"""Test create_cloned_volume."""
|
||||||
@ -240,7 +239,7 @@ class TestKaminarioCommon(test.TestCase):
|
|||||||
result = self.driver.create_cloned_volume(self.vol, self.vol)
|
result = self.driver.create_cloned_volume(self.vol, self.vol)
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
|
|
||||||
@mock.patch.object(utils, 'brick_get_connector_properties')
|
@mock.patch.object(volume_utils, 'brick_get_connector_properties')
|
||||||
@mock.patch.object(volume_utils, 'copy_volume')
|
@mock.patch.object(volume_utils, 'copy_volume')
|
||||||
def test_create_cloned_volume_with_exception(self, mock_copy_volume,
|
def test_create_cloned_volume_with_exception(self, mock_copy_volume,
|
||||||
mock_brick_get):
|
mock_brick_get):
|
||||||
|
@ -21,7 +21,6 @@ from six.moves import UserDict
|
|||||||
|
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.tests.unit import test
|
from cinder.tests.unit import test
|
||||||
from cinder import utils
|
|
||||||
from cinder.volume import configuration as conf
|
from cinder.volume import configuration as conf
|
||||||
from cinder.volume.drivers.macrosan import devop_client
|
from cinder.volume.drivers.macrosan import devop_client
|
||||||
from cinder.volume.drivers.macrosan import driver
|
from cinder.volume.drivers.macrosan import driver
|
||||||
@ -458,7 +457,7 @@ class MacroSANISCSIDriverTestCase(test.TestCase):
|
|||||||
@mock.patch.object(qos_specs, 'get_qos_specs',
|
@mock.patch.object(qos_specs, 'get_qos_specs',
|
||||||
return_value={'specs': {'qos-strategy': 'QoS-1'}})
|
return_value={'specs': {'qos-strategy': 'QoS-1'}})
|
||||||
@mock.patch.object(socket, 'gethostname', return_value='controller')
|
@mock.patch.object(socket, 'gethostname', return_value='controller')
|
||||||
@mock.patch.object(utils, 'brick_get_connector',
|
@mock.patch.object(volume_utils, 'brick_get_connector',
|
||||||
return_value=DummyBrickGetConnector())
|
return_value=DummyBrickGetConnector())
|
||||||
@mock.patch.object(volume_utils, 'copy_volume', return_value=None)
|
@mock.patch.object(volume_utils, 'copy_volume', return_value=None)
|
||||||
@mock.patch.object(os.path, 'realpath', return_value=None)
|
@mock.patch.object(os.path, 'realpath', return_value=None)
|
||||||
@ -478,7 +477,7 @@ class MacroSANISCSIDriverTestCase(test.TestCase):
|
|||||||
@mock.patch.object(qos_specs, 'get_qos_specs',
|
@mock.patch.object(qos_specs, 'get_qos_specs',
|
||||||
return_value={'specs': {'qos-strategy': 'QoS-1'}})
|
return_value={'specs': {'qos-strategy': 'QoS-1'}})
|
||||||
@mock.patch.object(socket, 'gethostname', return_value='controller')
|
@mock.patch.object(socket, 'gethostname', return_value='controller')
|
||||||
@mock.patch.object(utils, 'brick_get_connector',
|
@mock.patch.object(volume_utils, 'brick_get_connector',
|
||||||
return_value=DummyBrickGetConnector())
|
return_value=DummyBrickGetConnector())
|
||||||
@mock.patch.object(volume_utils, 'copy_volume', return_value=None)
|
@mock.patch.object(volume_utils, 'copy_volume', return_value=None)
|
||||||
@mock.patch.object(os.path, 'realpath', return_value=None)
|
@mock.patch.object(os.path, 'realpath', return_value=None)
|
||||||
@ -565,7 +564,7 @@ class MacroSANISCSIDriverTestCase(test.TestCase):
|
|||||||
@mock.patch.object(qos_specs, 'get_qos_specs',
|
@mock.patch.object(qos_specs, 'get_qos_specs',
|
||||||
return_value={'specs': {'qos-strategy': 'QoS-1'}})
|
return_value={'specs': {'qos-strategy': 'QoS-1'}})
|
||||||
@mock.patch.object(socket, 'gethostname', return_value='controller')
|
@mock.patch.object(socket, 'gethostname', return_value='controller')
|
||||||
@mock.patch.object(utils, 'brick_get_connector',
|
@mock.patch.object(volume_utils, 'brick_get_connector',
|
||||||
return_value=DummyBrickGetConnector())
|
return_value=DummyBrickGetConnector())
|
||||||
@mock.patch.object(volume_utils, 'copy_volume', return_value=None)
|
@mock.patch.object(volume_utils, 'copy_volume', return_value=None)
|
||||||
@mock.patch.object(os.path, 'realpath', return_value=None)
|
@mock.patch.object(os.path, 'realpath', return_value=None)
|
||||||
@ -586,7 +585,7 @@ class MacroSANISCSIDriverTestCase(test.TestCase):
|
|||||||
@mock.patch.object(qos_specs, 'get_qos_specs',
|
@mock.patch.object(qos_specs, 'get_qos_specs',
|
||||||
return_value={'specs': {'qos-strategy': 'QoS-1'}})
|
return_value={'specs': {'qos-strategy': 'QoS-1'}})
|
||||||
@mock.patch.object(socket, 'gethostname', return_value='controller')
|
@mock.patch.object(socket, 'gethostname', return_value='controller')
|
||||||
@mock.patch.object(utils, 'brick_get_connector',
|
@mock.patch.object(volume_utils, 'brick_get_connector',
|
||||||
return_value=DummyBrickGetConnector())
|
return_value=DummyBrickGetConnector())
|
||||||
@mock.patch.object(volume_utils, 'copy_volume', return_value=None)
|
@mock.patch.object(volume_utils, 'copy_volume', return_value=None)
|
||||||
@mock.patch.object(os.path, 'realpath', return_value=None)
|
@mock.patch.object(os.path, 'realpath', return_value=None)
|
||||||
@ -697,7 +696,7 @@ class MacroSANFCDriverTestCase(test.TestCase):
|
|||||||
@mock.patch.object(qos_specs, 'get_qos_specs',
|
@mock.patch.object(qos_specs, 'get_qos_specs',
|
||||||
return_value={'specs': {'qos-strategy': 'QoS-1'}})
|
return_value={'specs': {'qos-strategy': 'QoS-1'}})
|
||||||
@mock.patch.object(socket, 'gethostname', return_value='controller')
|
@mock.patch.object(socket, 'gethostname', return_value='controller')
|
||||||
@mock.patch.object(utils, 'brick_get_connector',
|
@mock.patch.object(volume_utils, 'brick_get_connector',
|
||||||
return_value=DummyBrickGetConnector())
|
return_value=DummyBrickGetConnector())
|
||||||
@mock.patch.object(volume_utils, 'copy_volume', return_value=None)
|
@mock.patch.object(volume_utils, 'copy_volume', return_value=None)
|
||||||
@mock.patch.object(os.path, 'realpath', return_value=None)
|
@mock.patch.object(os.path, 'realpath', return_value=None)
|
||||||
@ -718,7 +717,7 @@ class MacroSANFCDriverTestCase(test.TestCase):
|
|||||||
@mock.patch.object(qos_specs, 'get_qos_specs',
|
@mock.patch.object(qos_specs, 'get_qos_specs',
|
||||||
return_value={'specs': {'qos-strategy': 'QoS-1'}})
|
return_value={'specs': {'qos-strategy': 'QoS-1'}})
|
||||||
@mock.patch.object(socket, 'gethostname', return_value='controller')
|
@mock.patch.object(socket, 'gethostname', return_value='controller')
|
||||||
@mock.patch.object(utils, 'brick_get_connector',
|
@mock.patch.object(volume_utils, 'brick_get_connector',
|
||||||
return_value=DummyBrickGetConnector())
|
return_value=DummyBrickGetConnector())
|
||||||
@mock.patch.object(volume_utils, 'copy_volume', return_value=None)
|
@mock.patch.object(volume_utils, 'copy_volume', return_value=None)
|
||||||
@mock.patch.object(os.path, 'realpath', return_value=None)
|
@mock.patch.object(os.path, 'realpath', return_value=None)
|
||||||
@ -739,7 +738,7 @@ class MacroSANFCDriverTestCase(test.TestCase):
|
|||||||
@mock.patch.object(qos_specs, 'get_qos_specs',
|
@mock.patch.object(qos_specs, 'get_qos_specs',
|
||||||
return_value={'specs': {'qos-strategy': 'QoS-1'}})
|
return_value={'specs': {'qos-strategy': 'QoS-1'}})
|
||||||
@mock.patch.object(socket, 'gethostname', return_value='controller')
|
@mock.patch.object(socket, 'gethostname', return_value='controller')
|
||||||
@mock.patch.object(utils, 'brick_get_connector',
|
@mock.patch.object(volume_utils, 'brick_get_connector',
|
||||||
return_value=DummyBrickGetConnector())
|
return_value=DummyBrickGetConnector())
|
||||||
@mock.patch.object(volume_utils, 'copy_volume', return_value=None)
|
@mock.patch.object(volume_utils, 'copy_volume', return_value=None)
|
||||||
@mock.patch.object(os.path, 'realpath', return_value=None)
|
@mock.patch.object(os.path, 'realpath', return_value=None)
|
||||||
@ -761,7 +760,7 @@ class MacroSANFCDriverTestCase(test.TestCase):
|
|||||||
@mock.patch.object(qos_specs, 'get_qos_specs',
|
@mock.patch.object(qos_specs, 'get_qos_specs',
|
||||||
return_value={'specs': {'qos-strategy': 'QoS-1'}})
|
return_value={'specs': {'qos-strategy': 'QoS-1'}})
|
||||||
@mock.patch.object(socket, 'gethostname', return_value='controller')
|
@mock.patch.object(socket, 'gethostname', return_value='controller')
|
||||||
@mock.patch.object(utils, 'brick_get_connector',
|
@mock.patch.object(volume_utils, 'brick_get_connector',
|
||||||
return_value=DummyBrickGetConnector())
|
return_value=DummyBrickGetConnector())
|
||||||
@mock.patch.object(volume_utils, 'copy_volume', return_value=None)
|
@mock.patch.object(volume_utils, 'copy_volume', return_value=None)
|
||||||
@mock.patch.object(os.path, 'realpath', return_value=None)
|
@mock.patch.object(os.path, 'realpath', return_value=None)
|
||||||
|
@ -37,7 +37,6 @@ from cinder.tests.unit import fake_volume
|
|||||||
from cinder.tests.unit.image import fake as fake_image
|
from cinder.tests.unit.image import fake as fake_image
|
||||||
from cinder.tests.unit import test
|
from cinder.tests.unit import test
|
||||||
from cinder.tests.unit import utils as tests_utils
|
from cinder.tests.unit import utils as tests_utils
|
||||||
from cinder import utils
|
|
||||||
import cinder.volume
|
import cinder.volume
|
||||||
from cinder.volume import configuration as conf
|
from cinder.volume import configuration as conf
|
||||||
from cinder.volume import driver
|
from cinder.volume import driver
|
||||||
@ -272,7 +271,7 @@ class GenericVolumeDriverTestCase(BaseDriverTestCase):
|
|||||||
self.assertEqual('fakezone', temp_vol.availability_zone)
|
self.assertEqual('fakezone', temp_vol.availability_zone)
|
||||||
self.assertEqual('fakecluster', temp_vol.cluster_name)
|
self.assertEqual('fakecluster', temp_vol.cluster_name)
|
||||||
|
|
||||||
@mock.patch.object(utils, 'brick_get_connector_properties')
|
@mock.patch.object(volume_utils, 'brick_get_connector_properties')
|
||||||
@mock.patch.object(cinder.volume.manager.VolumeManager, '_attach_volume')
|
@mock.patch.object(cinder.volume.manager.VolumeManager, '_attach_volume')
|
||||||
@mock.patch.object(cinder.volume.manager.VolumeManager, '_detach_volume')
|
@mock.patch.object(cinder.volume.manager.VolumeManager, '_detach_volume')
|
||||||
@mock.patch.object(volume_utils, 'copy_volume')
|
@mock.patch.object(volume_utils, 'copy_volume')
|
||||||
@ -392,8 +391,10 @@ class GenericVolumeDriverTestCase(BaseDriverTestCase):
|
|||||||
@mock.patch.object(image_utils, 'fetch_to_raw')
|
@mock.patch.object(image_utils, 'fetch_to_raw')
|
||||||
@mock.patch.object(cinder.volume.driver.VolumeDriver, '_attach_volume')
|
@mock.patch.object(cinder.volume.driver.VolumeDriver, '_attach_volume')
|
||||||
@mock.patch.object(cinder.volume.driver.VolumeDriver, '_detach_volume')
|
@mock.patch.object(cinder.volume.driver.VolumeDriver, '_detach_volume')
|
||||||
@mock.patch.object(cinder.utils, 'brick_attach_volume_encryptor')
|
@mock.patch.object(cinder.volume.volume_utils,
|
||||||
@mock.patch.object(cinder.utils, 'brick_detach_volume_encryptor')
|
'brick_attach_volume_encryptor')
|
||||||
|
@mock.patch.object(cinder.volume.volume_utils,
|
||||||
|
'brick_detach_volume_encryptor')
|
||||||
def test_copy_image_to_encrypted_volume(self,
|
def test_copy_image_to_encrypted_volume(self,
|
||||||
mock_detach_encryptor,
|
mock_detach_encryptor,
|
||||||
mock_attach_encryptor,
|
mock_attach_encryptor,
|
||||||
@ -438,8 +439,10 @@ class GenericVolumeDriverTestCase(BaseDriverTestCase):
|
|||||||
@mock.patch.object(image_utils, 'fetch_to_raw')
|
@mock.patch.object(image_utils, 'fetch_to_raw')
|
||||||
@mock.patch.object(cinder.volume.driver.VolumeDriver, '_attach_volume')
|
@mock.patch.object(cinder.volume.driver.VolumeDriver, '_attach_volume')
|
||||||
@mock.patch.object(cinder.volume.driver.VolumeDriver, '_detach_volume')
|
@mock.patch.object(cinder.volume.driver.VolumeDriver, '_detach_volume')
|
||||||
@mock.patch.object(cinder.utils, 'brick_attach_volume_encryptor')
|
@mock.patch.object(cinder.volume.volume_utils,
|
||||||
@mock.patch.object(cinder.utils, 'brick_detach_volume_encryptor')
|
'brick_attach_volume_encryptor')
|
||||||
|
@mock.patch.object(cinder.volume.volume_utils,
|
||||||
|
'brick_detach_volume_encryptor')
|
||||||
def test_copy_image_to_encrypted_volume_failed_attach_encryptor(
|
def test_copy_image_to_encrypted_volume_failed_attach_encryptor(
|
||||||
self,
|
self,
|
||||||
mock_detach_encryptor,
|
mock_detach_encryptor,
|
||||||
@ -486,8 +489,10 @@ class GenericVolumeDriverTestCase(BaseDriverTestCase):
|
|||||||
@mock.patch.object(image_utils, 'fetch_to_raw')
|
@mock.patch.object(image_utils, 'fetch_to_raw')
|
||||||
@mock.patch.object(cinder.volume.driver.VolumeDriver, '_attach_volume')
|
@mock.patch.object(cinder.volume.driver.VolumeDriver, '_attach_volume')
|
||||||
@mock.patch.object(cinder.volume.driver.VolumeDriver, '_detach_volume')
|
@mock.patch.object(cinder.volume.driver.VolumeDriver, '_detach_volume')
|
||||||
@mock.patch.object(cinder.utils, 'brick_attach_volume_encryptor')
|
@mock.patch.object(cinder.volume.volume_utils,
|
||||||
@mock.patch.object(cinder.utils, 'brick_detach_volume_encryptor')
|
'brick_attach_volume_encryptor')
|
||||||
|
@mock.patch.object(cinder.volume.volume_utils,
|
||||||
|
'brick_detach_volume_encryptor')
|
||||||
@ddt.data(exception.ImageUnacceptable(
|
@ddt.data(exception.ImageUnacceptable(
|
||||||
reason='fake', image_id=fake.IMAGE_ID),
|
reason='fake', image_id=fake.IMAGE_ID),
|
||||||
exception.ImageTooBig(
|
exception.ImageTooBig(
|
||||||
|
@ -629,8 +629,8 @@ class ImageVolumeTestCases(base.BaseVolumeTestCase):
|
|||||||
self.assertRaises(exception.ImageTooBig,
|
self.assertRaises(exception.ImageTooBig,
|
||||||
self._create_volume_from_image)
|
self._create_volume_from_image)
|
||||||
|
|
||||||
@mock.patch('cinder.utils.brick_get_connector_properties')
|
@mock.patch('cinder.volume.volume_utils.brick_get_connector_properties')
|
||||||
@mock.patch('cinder.utils.brick_get_connector')
|
@mock.patch('cinder.volume.volume_utils.brick_get_connector')
|
||||||
@mock.patch('cinder.volume.driver.BaseVD.secure_file_operations_enabled')
|
@mock.patch('cinder.volume.driver.BaseVD.secure_file_operations_enabled')
|
||||||
@mock.patch('cinder.volume.driver.BaseVD._detach_volume')
|
@mock.patch('cinder.volume.driver.BaseVD._detach_volume')
|
||||||
@mock.patch('cinder.image.image_utils.qemu_img_info')
|
@mock.patch('cinder.image.image_utils.qemu_img_info')
|
||||||
@ -656,8 +656,8 @@ class ImageVolumeTestCases(base.BaseVolumeTestCase):
|
|||||||
# We must have called detach method.
|
# We must have called detach method.
|
||||||
self.assertEqual(1, mock_detach.call_count)
|
self.assertEqual(1, mock_detach.call_count)
|
||||||
|
|
||||||
@mock.patch('cinder.utils.brick_get_connector_properties')
|
@mock.patch('cinder.volume.volume_utils.brick_get_connector_properties')
|
||||||
@mock.patch('cinder.utils.brick_get_connector')
|
@mock.patch('cinder.volume.volume_utils.brick_get_connector')
|
||||||
@mock.patch('cinder.volume.driver.BaseVD._connect_device')
|
@mock.patch('cinder.volume.driver.BaseVD._connect_device')
|
||||||
@mock.patch('cinder.volume.driver.BaseVD._detach_volume')
|
@mock.patch('cinder.volume.driver.BaseVD._detach_volume')
|
||||||
@mock.patch('cinder.image.image_utils.qemu_img_info')
|
@mock.patch('cinder.image.image_utils.qemu_img_info')
|
||||||
|
@ -1685,7 +1685,7 @@ class VolumeTestCase(base.BaseVolumeTestCase):
|
|||||||
@mock.patch('cinder.image.image_utils.qemu_img_info')
|
@mock.patch('cinder.image.image_utils.qemu_img_info')
|
||||||
@mock.patch('cinder.volume.driver.VolumeDriver._detach_volume')
|
@mock.patch('cinder.volume.driver.VolumeDriver._detach_volume')
|
||||||
@mock.patch('cinder.volume.driver.VolumeDriver._attach_volume')
|
@mock.patch('cinder.volume.driver.VolumeDriver._attach_volume')
|
||||||
@mock.patch('cinder.utils.brick_get_connector_properties')
|
@mock.patch('cinder.volume.volume_utils.brick_get_connector_properties')
|
||||||
@mock.patch('cinder.utils.execute')
|
@mock.patch('cinder.utils.execute')
|
||||||
def test_create_volume_from_volume_with_enc(
|
def test_create_volume_from_volume_with_enc(
|
||||||
self, mock_execute, mock_brick_gcp, mock_at, mock_det,
|
self, mock_execute, mock_brick_gcp, mock_at, mock_det,
|
||||||
|
@ -213,7 +213,7 @@ class VolumeManagerTestCase(base.BaseVolumeTestCase):
|
|||||||
ctxt, None, vol, mock.sentinel.properties, force=True,
|
ctxt, None, vol, mock.sentinel.properties, force=True,
|
||||||
remote=mock.sentinel.remote)
|
remote=mock.sentinel.remote)
|
||||||
|
|
||||||
@mock.patch('cinder.utils.brick_attach_volume_encryptor')
|
@mock.patch('cinder.volume.volume_utils.brick_attach_volume_encryptor')
|
||||||
@mock.patch('cinder.volume.volume_types.is_encrypted')
|
@mock.patch('cinder.volume.volume_types.is_encrypted')
|
||||||
@mock.patch('cinder.volume.rpcapi.VolumeAPI')
|
@mock.patch('cinder.volume.rpcapi.VolumeAPI')
|
||||||
def test_attach_volume_fail_decrypt(self, mock_api, mock_is_encrypted,
|
def test_attach_volume_fail_decrypt(self, mock_api, mock_is_encrypted,
|
||||||
|
@ -37,11 +37,8 @@ import tempfile
|
|||||||
import time
|
import time
|
||||||
import types
|
import types
|
||||||
|
|
||||||
from castellan import key_manager
|
|
||||||
import eventlet
|
import eventlet
|
||||||
from eventlet import tpool
|
from eventlet import tpool
|
||||||
from os_brick import encryptors
|
|
||||||
from os_brick.initiator import connector
|
|
||||||
from oslo_concurrency import lockutils
|
from oslo_concurrency import lockutils
|
||||||
from oslo_concurrency import processutils
|
from oslo_concurrency import processutils
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
@ -420,73 +417,6 @@ def get_root_helper():
|
|||||||
return 'sudo cinder-rootwrap %s' % CONF.rootwrap_config
|
return 'sudo cinder-rootwrap %s' % CONF.rootwrap_config
|
||||||
|
|
||||||
|
|
||||||
def brick_get_connector_properties(multipath=False, enforce_multipath=False):
|
|
||||||
"""Wrapper to automatically set root_helper in brick calls.
|
|
||||||
|
|
||||||
:param multipath: A boolean indicating whether the connector can
|
|
||||||
support multipath.
|
|
||||||
:param enforce_multipath: If True, it raises exception when multipath=True
|
|
||||||
is specified but multipathd is not running.
|
|
||||||
If False, it falls back to multipath=False
|
|
||||||
when multipathd is not running.
|
|
||||||
"""
|
|
||||||
|
|
||||||
root_helper = get_root_helper()
|
|
||||||
return connector.get_connector_properties(root_helper,
|
|
||||||
CONF.my_ip,
|
|
||||||
multipath,
|
|
||||||
enforce_multipath)
|
|
||||||
|
|
||||||
|
|
||||||
def brick_get_connector(protocol, driver=None,
|
|
||||||
use_multipath=False,
|
|
||||||
device_scan_attempts=3,
|
|
||||||
*args, **kwargs):
|
|
||||||
"""Wrapper to get a brick connector object.
|
|
||||||
|
|
||||||
This automatically populates the required protocol as well
|
|
||||||
as the root_helper needed to execute commands.
|
|
||||||
"""
|
|
||||||
|
|
||||||
root_helper = get_root_helper()
|
|
||||||
return connector.InitiatorConnector.factory(protocol, root_helper,
|
|
||||||
driver=driver,
|
|
||||||
use_multipath=use_multipath,
|
|
||||||
device_scan_attempts=
|
|
||||||
device_scan_attempts,
|
|
||||||
*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
def brick_get_encryptor(connection_info, *args, **kwargs):
|
|
||||||
"""Wrapper to get a brick encryptor object."""
|
|
||||||
|
|
||||||
root_helper = get_root_helper()
|
|
||||||
km = key_manager.API(CONF)
|
|
||||||
return encryptors.get_volume_encryptor(root_helper=root_helper,
|
|
||||||
connection_info=connection_info,
|
|
||||||
keymgr=km,
|
|
||||||
*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
def brick_attach_volume_encryptor(context, attach_info, encryption):
|
|
||||||
"""Attach encryption layer."""
|
|
||||||
connection_info = attach_info['conn']
|
|
||||||
connection_info['data']['device_path'] = attach_info['device']['path']
|
|
||||||
encryptor = brick_get_encryptor(connection_info,
|
|
||||||
**encryption)
|
|
||||||
encryptor.attach_volume(context, **encryption)
|
|
||||||
|
|
||||||
|
|
||||||
def brick_detach_volume_encryptor(attach_info, encryption):
|
|
||||||
"""Detach encryption layer."""
|
|
||||||
connection_info = attach_info['conn']
|
|
||||||
connection_info['data']['device_path'] = attach_info['device']['path']
|
|
||||||
|
|
||||||
encryptor = brick_get_encryptor(connection_info,
|
|
||||||
**encryption)
|
|
||||||
encryptor.detach_volume(**encryption)
|
|
||||||
|
|
||||||
|
|
||||||
def require_driver_initialized(driver):
|
def require_driver_initialized(driver):
|
||||||
"""Verifies if `driver` is initialized
|
"""Verifies if `driver` is initialized
|
||||||
|
|
||||||
|
@ -870,16 +870,17 @@ class BaseVD(object, metaclass=abc.ABCMeta):
|
|||||||
|
|
||||||
use_multipath = self.configuration.use_multipath_for_image_xfer
|
use_multipath = self.configuration.use_multipath_for_image_xfer
|
||||||
enforce_multipath = self.configuration.enforce_multipath_for_image_xfer
|
enforce_multipath = self.configuration.enforce_multipath_for_image_xfer
|
||||||
properties = utils.brick_get_connector_properties(use_multipath,
|
properties = volume_utils.brick_get_connector_properties(
|
||||||
enforce_multipath)
|
use_multipath,
|
||||||
|
enforce_multipath)
|
||||||
attach_info, volume = self._attach_volume(context, volume, properties)
|
attach_info, volume = self._attach_volume(context, volume, properties)
|
||||||
try:
|
try:
|
||||||
if encrypted:
|
if encrypted:
|
||||||
encryption = self.db.volume_encryption_metadata_get(context,
|
encryption = self.db.volume_encryption_metadata_get(context,
|
||||||
volume.id)
|
volume.id)
|
||||||
utils.brick_attach_volume_encryptor(context,
|
volume_utils.brick_attach_volume_encryptor(context,
|
||||||
attach_info,
|
attach_info,
|
||||||
encryption)
|
encryption)
|
||||||
try:
|
try:
|
||||||
image_utils.fetch_to_raw(
|
image_utils.fetch_to_raw(
|
||||||
context,
|
context,
|
||||||
@ -897,8 +898,8 @@ class BaseVD(object, metaclass=abc.ABCMeta):
|
|||||||
|
|
||||||
finally:
|
finally:
|
||||||
if encrypted:
|
if encrypted:
|
||||||
utils.brick_detach_volume_encryptor(attach_info,
|
volume_utils.brick_detach_volume_encryptor(attach_info,
|
||||||
encryption)
|
encryption)
|
||||||
finally:
|
finally:
|
||||||
self._detach_volume(context, attach_info, volume, properties,
|
self._detach_volume(context, attach_info, volume, properties,
|
||||||
force=True)
|
force=True)
|
||||||
@ -909,8 +910,9 @@ class BaseVD(object, metaclass=abc.ABCMeta):
|
|||||||
|
|
||||||
use_multipath = self.configuration.use_multipath_for_image_xfer
|
use_multipath = self.configuration.use_multipath_for_image_xfer
|
||||||
enforce_multipath = self.configuration.enforce_multipath_for_image_xfer
|
enforce_multipath = self.configuration.enforce_multipath_for_image_xfer
|
||||||
properties = utils.brick_get_connector_properties(use_multipath,
|
properties = volume_utils.brick_get_connector_properties(
|
||||||
enforce_multipath)
|
use_multipath,
|
||||||
|
enforce_multipath)
|
||||||
attach_info, volume = self._attach_volume(context, volume, properties)
|
attach_info, volume = self._attach_volume(context, volume, properties)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -1125,7 +1127,7 @@ class BaseVD(object, metaclass=abc.ABCMeta):
|
|||||||
use_multipath = self.configuration.use_multipath_for_image_xfer
|
use_multipath = self.configuration.use_multipath_for_image_xfer
|
||||||
device_scan_attempts = self.configuration.num_volume_device_scan_tries
|
device_scan_attempts = self.configuration.num_volume_device_scan_tries
|
||||||
protocol = conn['driver_volume_type']
|
protocol = conn['driver_volume_type']
|
||||||
connector = utils.brick_get_connector(
|
connector = volume_utils.brick_get_connector(
|
||||||
protocol,
|
protocol,
|
||||||
use_multipath=use_multipath,
|
use_multipath=use_multipath,
|
||||||
device_scan_attempts=device_scan_attempts,
|
device_scan_attempts=device_scan_attempts,
|
||||||
|
@ -31,7 +31,6 @@ import six
|
|||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _
|
from cinder.i18n import _
|
||||||
from cinder.image import image_utils
|
from cinder.image import image_utils
|
||||||
from cinder import utils
|
|
||||||
import cinder.volume.drivers.datera.datera_common as datc
|
import cinder.volume.drivers.datera.datera_common as datc
|
||||||
from cinder.volume import volume_types
|
from cinder.volume import volume_types
|
||||||
from cinder.volume import volume_utils as volutils
|
from cinder.volume import volume_utils as volutils
|
||||||
@ -885,7 +884,7 @@ class DateraApi(object):
|
|||||||
# export (ACL, IP-Pools, etc)
|
# export (ACL, IP-Pools, etc)
|
||||||
conn = self._initialize_connection_2_1(
|
conn = self._initialize_connection_2_1(
|
||||||
vol, {'multipath': False})
|
vol, {'multipath': False})
|
||||||
connector = utils.brick_get_connector(
|
connector = volutils.brick_get_connector(
|
||||||
conn['driver_volume_type'],
|
conn['driver_volume_type'],
|
||||||
use_multipath=False,
|
use_multipath=False,
|
||||||
device_scan_attempts=10,
|
device_scan_attempts=10,
|
||||||
|
@ -31,7 +31,6 @@ import six
|
|||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _
|
from cinder.i18n import _
|
||||||
from cinder.image import image_utils
|
from cinder.image import image_utils
|
||||||
from cinder import utils
|
|
||||||
import cinder.volume.drivers.datera.datera_common as datc
|
import cinder.volume.drivers.datera.datera_common as datc
|
||||||
from cinder.volume import volume_types
|
from cinder.volume import volume_types
|
||||||
from cinder.volume import volume_utils as volutils
|
from cinder.volume import volume_utils as volutils
|
||||||
@ -935,7 +934,7 @@ class DateraApi(object):
|
|||||||
# export (ACL, IP-Pools, etc)
|
# export (ACL, IP-Pools, etc)
|
||||||
conn = self._initialize_connection_2_2(
|
conn = self._initialize_connection_2_2(
|
||||||
vol, {'multipath': False})
|
vol, {'multipath': False})
|
||||||
connector = utils.brick_get_connector(
|
connector = volutils.brick_get_connector(
|
||||||
conn['driver_volume_type'],
|
conn['driver_volume_type'],
|
||||||
use_multipath=False,
|
use_multipath=False,
|
||||||
device_scan_attempts=10,
|
device_scan_attempts=10,
|
||||||
|
@ -813,7 +813,7 @@ class CommonAdapter(object):
|
|||||||
is_compressed=vol_params.is_compressed)
|
is_compressed=vol_params.is_compressed)
|
||||||
src_id = src_snap.get_id()
|
src_id = src_snap.get_id()
|
||||||
try:
|
try:
|
||||||
conn_props = cinder_utils.brick_get_connector_properties()
|
conn_props = volume_utils.brick_get_connector_properties()
|
||||||
|
|
||||||
with self._connect_resource(dest_lun, conn_props,
|
with self._connect_resource(dest_lun, conn_props,
|
||||||
vol_params.volume_id) as dest_info, \
|
vol_params.volume_id) as dest_info, \
|
||||||
|
@ -22,7 +22,6 @@ from oslo_utils import excutils
|
|||||||
|
|
||||||
from cinder import coordination
|
from cinder import coordination
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder import utils as cinder_utils
|
|
||||||
from cinder.volume import configuration
|
from cinder.volume import configuration
|
||||||
from cinder.volume.drivers.hitachi import hbsd_utils as utils
|
from cinder.volume.drivers.hitachi import hbsd_utils as utils
|
||||||
from cinder.volume import volume_utils
|
from cinder.volume import volume_utils
|
||||||
@ -582,7 +581,7 @@ class HBSDCommon():
|
|||||||
"""Initialize server-storage connection."""
|
"""Initialize server-storage connection."""
|
||||||
targets = kwargs.pop(
|
targets = kwargs.pop(
|
||||||
'targets', {'info': {}, 'list': [], 'iqns': {}, 'target_map': {}})
|
'targets', {'info': {}, 'list': [], 'iqns': {}, 'target_map': {}})
|
||||||
connector = cinder_utils.brick_get_connector_properties(
|
connector = volume_utils.brick_get_connector_properties(
|
||||||
multipath=self.conf.use_multipath_for_image_xfer,
|
multipath=self.conf.use_multipath_for_image_xfer,
|
||||||
enforce_multipath=self.conf.enforce_multipath_for_image_xfer)
|
enforce_multipath=self.conf.enforce_multipath_for_image_xfer)
|
||||||
target_ports = self.storage_info['controller_ports']
|
target_ports = self.storage_info['controller_ports']
|
||||||
|
@ -219,7 +219,7 @@ class FlashSystemDriver(san.SanDriver,
|
|||||||
LOG.debug('enter: _copy_vdisk_data: %(src)s -> %(dest)s.',
|
LOG.debug('enter: _copy_vdisk_data: %(src)s -> %(dest)s.',
|
||||||
{'src': src_vdisk_name, 'dest': dest_vdisk_name})
|
{'src': src_vdisk_name, 'dest': dest_vdisk_name})
|
||||||
|
|
||||||
connector = utils.brick_get_connector_properties()
|
connector = volume_utils.brick_get_connector_properties()
|
||||||
(src_map, src_lun_id) = self._is_vdisk_map(
|
(src_map, src_lun_id) = self._is_vdisk_map(
|
||||||
src_vdisk_name, connector)
|
src_vdisk_name, connector)
|
||||||
(dest_map, dest_lun_id) = self._is_vdisk_map(
|
(dest_map, dest_lun_id) = self._is_vdisk_map(
|
||||||
@ -852,11 +852,12 @@ class FlashSystemDriver(san.SanDriver,
|
|||||||
use_multipath = self.configuration.use_multipath_for_image_xfer
|
use_multipath = self.configuration.use_multipath_for_image_xfer
|
||||||
device_scan_attempts = self.configuration.num_volume_device_scan_tries
|
device_scan_attempts = self.configuration.num_volume_device_scan_tries
|
||||||
protocol = properties['driver_volume_type']
|
protocol = properties['driver_volume_type']
|
||||||
connector = utils.brick_get_connector(protocol,
|
connector = volume_utils.brick_get_connector(
|
||||||
use_multipath=use_multipath,
|
protocol,
|
||||||
device_scan_attempts=
|
use_multipath=use_multipath,
|
||||||
device_scan_attempts,
|
device_scan_attempts=
|
||||||
conn=properties)
|
device_scan_attempts,
|
||||||
|
conn=properties)
|
||||||
|
|
||||||
connector.disconnect_volume(properties['data'], device)
|
connector.disconnect_volume(properties['data'], device)
|
||||||
|
|
||||||
@ -888,11 +889,12 @@ class FlashSystemDriver(san.SanDriver,
|
|||||||
use_multipath = self.configuration.use_multipath_for_image_xfer
|
use_multipath = self.configuration.use_multipath_for_image_xfer
|
||||||
device_scan_attempts = self.configuration.num_volume_device_scan_tries
|
device_scan_attempts = self.configuration.num_volume_device_scan_tries
|
||||||
protocol = properties['driver_volume_type']
|
protocol = properties['driver_volume_type']
|
||||||
connector = utils.brick_get_connector(protocol,
|
connector = volume_utils.brick_get_connector(
|
||||||
use_multipath=use_multipath,
|
protocol,
|
||||||
device_scan_attempts=
|
use_multipath=use_multipath,
|
||||||
device_scan_attempts,
|
device_scan_attempts=
|
||||||
conn=properties)
|
device_scan_attempts,
|
||||||
|
conn=properties)
|
||||||
device = connector.connect_volume(properties['data'])
|
device = connector.connect_volume(properties['data'])
|
||||||
host_device = device['path']
|
host_device = device['path']
|
||||||
|
|
||||||
|
@ -29,7 +29,6 @@ from cinder import exception
|
|||||||
from cinder.i18n import _
|
from cinder.i18n import _
|
||||||
from cinder import interface
|
from cinder import interface
|
||||||
from cinder.objects import fields
|
from cinder.objects import fields
|
||||||
from cinder import utils
|
|
||||||
from cinder import version
|
from cinder import version
|
||||||
from cinder.volume import configuration
|
from cinder.volume import configuration
|
||||||
from cinder.volume.drivers.san import san
|
from cinder.volume.drivers.san import san
|
||||||
@ -569,8 +568,9 @@ class InfiniboxVolumeDriver(san.SanISCSIDriver):
|
|||||||
def _connection_context(self, volume):
|
def _connection_context(self, volume):
|
||||||
use_multipath = self.configuration.use_multipath_for_image_xfer
|
use_multipath = self.configuration.use_multipath_for_image_xfer
|
||||||
enforce_multipath = self.configuration.enforce_multipath_for_image_xfer
|
enforce_multipath = self.configuration.enforce_multipath_for_image_xfer
|
||||||
connector = utils.brick_get_connector_properties(use_multipath,
|
connector = volume_utils.brick_get_connector_properties(
|
||||||
enforce_multipath)
|
use_multipath,
|
||||||
|
enforce_multipath)
|
||||||
connection = self.initialize_connection(volume, connector)
|
connection = self.initialize_connection(volume, connector)
|
||||||
try:
|
try:
|
||||||
yield connection
|
yield connection
|
||||||
@ -582,7 +582,7 @@ class InfiniboxVolumeDriver(san.SanISCSIDriver):
|
|||||||
use_multipath = self.configuration.use_multipath_for_image_xfer
|
use_multipath = self.configuration.use_multipath_for_image_xfer
|
||||||
device_scan_attempts = self.configuration.num_volume_device_scan_tries
|
device_scan_attempts = self.configuration.num_volume_device_scan_tries
|
||||||
protocol = connection['driver_volume_type']
|
protocol = connection['driver_volume_type']
|
||||||
connector = utils.brick_get_connector(
|
connector = volume_utils.brick_get_connector(
|
||||||
protocol,
|
protocol,
|
||||||
use_multipath=use_multipath,
|
use_multipath=use_multipath,
|
||||||
device_scan_attempts=device_scan_attempts,
|
device_scan_attempts=device_scan_attempts,
|
||||||
|
@ -553,7 +553,7 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
|||||||
vol_name = self.get_volume_name(volume.id)
|
vol_name = self.get_volume_name(volume.id)
|
||||||
cview = src_attach_info = dest_attach_info = None
|
cview = src_attach_info = dest_attach_info = None
|
||||||
rpolicy = self.get_policy()
|
rpolicy = self.get_policy()
|
||||||
properties = utils.brick_get_connector_properties()
|
properties = volume_utils.brick_get_connector_properties()
|
||||||
LOG.debug("Searching for snapshot: %s in K2.", snap_name)
|
LOG.debug("Searching for snapshot: %s in K2.", snap_name)
|
||||||
snap_rs = self.client.search("snapshots", short_name=snap_name)
|
snap_rs = self.client.search("snapshots", short_name=snap_name)
|
||||||
if hasattr(snap_rs, 'hits') and snap_rs.total != 0:
|
if hasattr(snap_rs, 'hits') and snap_rs.total != 0:
|
||||||
@ -624,7 +624,7 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
|||||||
LOG.error(msg)
|
LOG.error(msg)
|
||||||
raise KaminarioCinderDriverException(reason=msg)
|
raise KaminarioCinderDriverException(reason=msg)
|
||||||
try:
|
try:
|
||||||
properties = utils.brick_get_connector_properties()
|
properties = volume_utils.brick_get_connector_properties()
|
||||||
conn = self.initialize_connection(src_vref, properties)
|
conn = self.initialize_connection(src_vref, properties)
|
||||||
src_attach_info = self._connect_device(conn)
|
src_attach_info = self._connect_device(conn)
|
||||||
self.create_volume(volume)
|
self.create_volume(volume)
|
||||||
|
@ -509,7 +509,7 @@ class CreateVolumeFromSpecTask(flow_utils.CinderTask):
|
|||||||
|
|
||||||
LOG.debug('rekey volume %s', volume.name)
|
LOG.debug('rekey volume %s', volume.name)
|
||||||
|
|
||||||
properties = utils.brick_get_connector_properties(False, False)
|
properties = volume_utils.brick_get_connector_properties(False, False)
|
||||||
LOG.debug("properties: %s", properties)
|
LOG.debug("properties: %s", properties)
|
||||||
attach_info = None
|
attach_info = None
|
||||||
model_update = {}
|
model_update = {}
|
||||||
|
@ -2038,7 +2038,7 @@ class VolumeManager(manager.CleanableManager,
|
|||||||
use_multipath = self.configuration.use_multipath_for_image_xfer
|
use_multipath = self.configuration.use_multipath_for_image_xfer
|
||||||
device_scan_attempts = self.configuration.num_volume_device_scan_tries
|
device_scan_attempts = self.configuration.num_volume_device_scan_tries
|
||||||
protocol = conn['driver_volume_type']
|
protocol = conn['driver_volume_type']
|
||||||
connector = utils.brick_get_connector(
|
connector = volume_utils.brick_get_connector(
|
||||||
protocol,
|
protocol,
|
||||||
use_multipath=use_multipath,
|
use_multipath=use_multipath,
|
||||||
device_scan_attempts=device_scan_attempts,
|
device_scan_attempts=device_scan_attempts,
|
||||||
@ -2088,9 +2088,9 @@ class VolumeManager(manager.CleanableManager,
|
|||||||
encryption = self.db.volume_encryption_metadata_get(
|
encryption = self.db.volume_encryption_metadata_get(
|
||||||
ctxt.elevated(), volume.id)
|
ctxt.elevated(), volume.id)
|
||||||
if encryption:
|
if encryption:
|
||||||
utils.brick_attach_volume_encryptor(ctxt,
|
volume_utils.brick_attach_volume_encryptor(ctxt,
|
||||||
attach_info,
|
attach_info,
|
||||||
encryption)
|
encryption)
|
||||||
except Exception:
|
except Exception:
|
||||||
with excutils.save_and_reraise_exception():
|
with excutils.save_and_reraise_exception():
|
||||||
LOG.error("Failed to attach volume encryptor"
|
LOG.error("Failed to attach volume encryptor"
|
||||||
@ -2110,8 +2110,8 @@ class VolumeManager(manager.CleanableManager,
|
|||||||
encryption = self.db.volume_encryption_metadata_get(
|
encryption = self.db.volume_encryption_metadata_get(
|
||||||
ctxt.elevated(), volume.id)
|
ctxt.elevated(), volume.id)
|
||||||
if encryption:
|
if encryption:
|
||||||
utils.brick_detach_volume_encryptor(attach_info,
|
volume_utils.brick_detach_volume_encryptor(attach_info,
|
||||||
encryption)
|
encryption)
|
||||||
connector.disconnect_volume(attach_info['conn']['data'],
|
connector.disconnect_volume(attach_info['conn']['data'],
|
||||||
attach_info['device'], force=force)
|
attach_info['device'], force=force)
|
||||||
|
|
||||||
@ -2144,8 +2144,9 @@ class VolumeManager(manager.CleanableManager,
|
|||||||
attach_encryptor = True
|
attach_encryptor = True
|
||||||
use_multipath = self.configuration.use_multipath_for_image_xfer
|
use_multipath = self.configuration.use_multipath_for_image_xfer
|
||||||
enforce_multipath = self.configuration.enforce_multipath_for_image_xfer
|
enforce_multipath = self.configuration.enforce_multipath_for_image_xfer
|
||||||
properties = utils.brick_get_connector_properties(use_multipath,
|
properties = volume_utils.brick_get_connector_properties(
|
||||||
enforce_multipath)
|
use_multipath,
|
||||||
|
enforce_multipath)
|
||||||
|
|
||||||
dest_remote = remote in ['dest', 'both']
|
dest_remote = remote in ['dest', 'both']
|
||||||
dest_attach_info = self._attach_volume(
|
dest_attach_info = self._attach_volume(
|
||||||
|
@ -35,6 +35,7 @@ import eventlet
|
|||||||
from eventlet import tpool
|
from eventlet import tpool
|
||||||
from keystoneauth1 import loading as ks_loading
|
from keystoneauth1 import loading as ks_loading
|
||||||
from os_brick import encryptors
|
from os_brick import encryptors
|
||||||
|
from os_brick.initiator import connector
|
||||||
from oslo_concurrency import processutils
|
from oslo_concurrency import processutils
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
@ -1295,3 +1296,70 @@ def get_backend_configuration(backend_name, backend_opts=None):
|
|||||||
config.append_config_values(backend_opts)
|
config.append_config_values(backend_opts)
|
||||||
|
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
|
||||||
|
def brick_get_connector_properties(multipath=False, enforce_multipath=False):
|
||||||
|
"""Wrapper to automatically set root_helper in brick calls.
|
||||||
|
|
||||||
|
:param multipath: A boolean indicating whether the connector can
|
||||||
|
support multipath.
|
||||||
|
:param enforce_multipath: If True, it raises exception when multipath=True
|
||||||
|
is specified but multipathd is not running.
|
||||||
|
If False, it falls back to multipath=False
|
||||||
|
when multipathd is not running.
|
||||||
|
"""
|
||||||
|
|
||||||
|
root_helper = utils.get_root_helper()
|
||||||
|
return connector.get_connector_properties(root_helper,
|
||||||
|
CONF.my_ip,
|
||||||
|
multipath,
|
||||||
|
enforce_multipath)
|
||||||
|
|
||||||
|
|
||||||
|
def brick_get_connector(protocol, driver=None,
|
||||||
|
use_multipath=False,
|
||||||
|
device_scan_attempts=3,
|
||||||
|
*args, **kwargs):
|
||||||
|
"""Wrapper to get a brick connector object.
|
||||||
|
|
||||||
|
This automatically populates the required protocol as well
|
||||||
|
as the root_helper needed to execute commands.
|
||||||
|
"""
|
||||||
|
|
||||||
|
root_helper = utils.get_root_helper()
|
||||||
|
return connector.InitiatorConnector.factory(protocol, root_helper,
|
||||||
|
driver=driver,
|
||||||
|
use_multipath=use_multipath,
|
||||||
|
device_scan_attempts=
|
||||||
|
device_scan_attempts,
|
||||||
|
*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
def brick_get_encryptor(connection_info, *args, **kwargs):
|
||||||
|
"""Wrapper to get a brick encryptor object."""
|
||||||
|
|
||||||
|
root_helper = utils.get_root_helper()
|
||||||
|
km = castellan_key_manager.API(CONF)
|
||||||
|
return encryptors.get_volume_encryptor(root_helper=root_helper,
|
||||||
|
connection_info=connection_info,
|
||||||
|
keymgr=km,
|
||||||
|
*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
def brick_attach_volume_encryptor(context, attach_info, encryption):
|
||||||
|
"""Attach encryption layer."""
|
||||||
|
connection_info = attach_info['conn']
|
||||||
|
connection_info['data']['device_path'] = attach_info['device']['path']
|
||||||
|
encryptor = brick_get_encryptor(connection_info,
|
||||||
|
**encryption)
|
||||||
|
encryptor.attach_volume(context, **encryption)
|
||||||
|
|
||||||
|
|
||||||
|
def brick_detach_volume_encryptor(attach_info, encryption):
|
||||||
|
"""Detach encryption layer."""
|
||||||
|
connection_info = attach_info['conn']
|
||||||
|
connection_info['data']['device_path'] = attach_info['device']['path']
|
||||||
|
|
||||||
|
encryptor = brick_get_encryptor(connection_info,
|
||||||
|
**encryption)
|
||||||
|
encryptor.detach_volume(**encryption)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user