False,
None,
'default')
- lvm_driver.sparse_copy_volume = True
+ lvm_driver._sparse_copy_volume = True
moved, model_update = \
lvm_driver.migrate_volume(self.context, vol, host)
self.assertTrue(moved)
mock.patch.object(volutils, 'copy_volume') as mock_copy:
# Test case for thin LVM
- lvm_driver.sparse_copy_volume = True
+ lvm_driver._sparse_copy_volume = True
src_volume = tests_utils.create_volume(self.context)
snapshot_ref = tests_utils.create_snapshot(self.context,
src_volume['id'])
self.assertEqual(["iqn:iqn", "iqn:iqn"], result["target_iqns"])
self.assertEqual([0, 0], result["target_luns"])
- def test_get_volume_stats(self):
+ @mock.patch('cinder.brick.local_dev.lvm.LVM.get_lvm_version',
+ return_value=(2, 2, 100))
+ def test_get_volume_stats(self, _mock_get_version):
def _fake_get_all_physical_volumes(obj, root_helper, vg_name):
return [{}]
- def _fake_get_all_volume_groups(obj, vg_name=None, no_suffix=True):
+ @staticmethod
+ def _fake_get_all_volume_groups(root_helper, vg_name=None):
return [{'name': 'cinder-volumes',
'size': '5.52',
'available': '0.52',
self.assertFalse(stats['sparse_copy_volume'])
# Check value of sparse_copy_volume for thin enabled case.
+ # This value is set in check_for_setup_error.
self.configuration = conf.Configuration(None)
self.configuration.lvm_type = 'thin'
+ vg_obj = fake_lvm.FakeBrickLVM('cinder-volumes',
+ False,
+ None,
+ 'default')
lvm_driver = lvm.LVMVolumeDriver(configuration=self.configuration,
- db=db)
+ db=db,
+ vg_obj=vg_obj)
+ lvm_driver.check_for_setup_error()
lvm_driver.vg = brick_lvm.LVM('cinder-volumes', 'sudo')
lvm_driver._update_volume_stats()
stats = lvm_driver._stats
db=self.db,
executor=self._execute)
self.protocol = self.target_driver.protocol
- self.sparse_copy_volume = False
+ self._sparse_copy_volume = False
def _sizestr(self, size_in_g):
return '%sg' % size_in_g
data["pools"].append(single_pool)
# Check availability of sparse volume copy.
- data['sparse_copy_volume'] = self.configuration.lvm_type == 'thin'
+ data['sparse_copy_volume'] = self._sparse_copy_volume
self._stats = data
data=exception_message)
# Enable sparse copy since lvm_type is 'thin'
- self.sparse_copy_volume = True
+ self._sparse_copy_volume = True
def create_volume(self, volume):
"""Creates a logical volume."""
snapshot['volume_size'] * units.Ki,
self.configuration.volume_dd_blocksize,
execute=self._execute,
- sparse=self.sparse_copy_volume)
+ sparse=self._sparse_copy_volume)
def delete_volume(self, volume):
"""Deletes a logical volume."""
src_vref['size'] * units.Ki,
self.configuration.volume_dd_blocksize,
execute=self._execute,
- sparse=self.sparse_copy_volume)
+ sparse=self._sparse_copy_volume)
finally:
self.delete_snapshot(temp_snapshot)
size_in_mb,
self.configuration.volume_dd_blocksize,
execute=self._execute,
- sparse=self.sparse_copy_volume)
+ sparse=self._sparse_copy_volume)
except Exception as e:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Volume migration failed due to "