Merge "LVM: Volume is deleted unexpectedly during volume migration"
This commit is contained in:
commit
4fd4e53a63
|
@ -3752,6 +3752,23 @@ class LVMISCSIVolumeDriverTestCase(DriverTestCase):
|
|||
self.assertEqual(moved, False)
|
||||
self.assertIsNone(model_update)
|
||||
|
||||
@mock.patch.object(volutils, 'get_all_volume_groups',
|
||||
return_value=[{'name': 'cinder-volumes'}])
|
||||
def test_lvm_migrate_volume_same_volume_group(self, vgs):
|
||||
hostname = socket.gethostname()
|
||||
capabilities = {'location_info': 'LVMVolumeDriver:%s:'
|
||||
'cinder-volumes:default:0' % hostname}
|
||||
host = {'capabilities': capabilities}
|
||||
vol = {'name': 'test', 'id': 1, 'size': 1, 'status': 'available'}
|
||||
self.volume.driver.vg = FakeBrickLVM('cinder-volumes',
|
||||
False,
|
||||
None,
|
||||
'default')
|
||||
|
||||
self.assertRaises(exception.VolumeBackendAPIException,
|
||||
self.volume.driver.migrate_volume, self.context,
|
||||
vol, host)
|
||||
|
||||
def test_lvm_volume_group_missing(self):
|
||||
hostname = socket.gethostname()
|
||||
capabilities = {'location_info': 'LVMVolumeDriver:%s:'
|
||||
|
|
|
@ -626,15 +626,22 @@ class LVMISCSIDriver(LVMVolumeDriver, driver.ISCSIDriver):
|
|||
lvm_mirrors,
|
||||
dest_vg_ref)
|
||||
|
||||
volutils.copy_volume(self.local_path(volume),
|
||||
self.local_path(volume, vg=dest_vg),
|
||||
volume['size'],
|
||||
self.configuration.volume_dd_blocksize,
|
||||
execute=self._execute)
|
||||
self._delete_volume(volume)
|
||||
model_update = self._create_export(ctxt, volume, vg=dest_vg)
|
||||
volutils.copy_volume(self.local_path(volume),
|
||||
self.local_path(volume, vg=dest_vg),
|
||||
volume['size'],
|
||||
self.configuration.volume_dd_blocksize,
|
||||
execute=self._execute)
|
||||
self._delete_volume(volume)
|
||||
model_update = self._create_export(ctxt, volume, vg=dest_vg)
|
||||
|
||||
return (True, model_update)
|
||||
return (True, model_update)
|
||||
else:
|
||||
message = (_("Refusing to migrate volume ID: %(id)s. Please "
|
||||
"check your configuration because source and "
|
||||
"destination are the same Volume Group: %(name)s.")
|
||||
% {'id': volume['id'], 'name': self.vg.vg_name})
|
||||
LOG.exception(message)
|
||||
raise exception.VolumeBackendAPIException(data=message)
|
||||
|
||||
def _iscsi_location(self, ip, target, iqn, lun=None):
|
||||
return "%s:%s,%s %s %s" % (ip, self.configuration.iscsi_port,
|
||||
|
|
Loading…
Reference in New Issue